[Haskell-cafe] Problem trying to get class Bounded to work

Brian Hulley brianh at metamilk.com
Tue May 23 17:56:38 EDT 2006


Benjamin Franksen wrote:
> On Tuesday 23 May 2006 02:00, Brian Hulley wrote:
>> I wonder if Haskell' will automatically make type variables scope
>> over the function body (without an explicit forall)? Is there any
>> reason why they shouldn't always do so?
>
> One I can think of is that the type signature for a function may be at
> the other end of the file. Some discussion about the pros and cons can
> be found here
>
> http://www.mail-archive.com/haskell%40haskell.org/msg15738.html
>
> and here
>
> http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/9219

Thanks for the links. I hadn't realised there were so many hard choices to 
make in the design of the type system and that it is not clear that there is 
a unique correct answer to the problem. I'll have to do some further reading 
to find the meaning of "rigid" and "wobbly" and "non-type type variables" or 
type variables which are not types... ;-)

I must admit I also don't understand why there is a difference between let 
bindings and case bindings. (I know let bindings are lazy but I don't see 
what difference this makes to the type system) Or is the difference just due 
to the desire to still have a monomorphism restriction and/or limitations 
with HM type inference? Would the difference be needed if a different type 
system (eg intersection types with principal *typing* property instead of HM 
types which only have a principal types property) were used?

I was very surprised at the decision to use the otherwise redundant "forall" 
to make a distinction between whether or not type variables are scoped, 
since a simple compiler option could have been used to turn on/off implicit 
scoping instead to preserve compatibility with H98 modules.

One issue seems to be that H98 compatibility (eg implicit forall) is 
fundamentally incompatible with a simple uniform approach to typing in the 
presence of all the advanced type extensions that have been added since H98 
was designed.

It still seems there are too many different cases. Perhaps there are 
conflicting demands on the type system and the rejection of some of these 
demands would lead to a simpler solution?

Robert Dockins wrote:
> GHC has an extension to allow scoped type variables and there's also
> a Haskell' ticket for it.
>
> http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#scoped-type-variables
> http://hackage.haskell.org/trac/haskell-prime/wiki/ScopedTypeVariables

Hopefully the ticket will get more detailed and concrete and 
rationally-reconstructed to remove the existing quirks and "thence grow to a 
point" as Shakespeare might have said, in due course.

Regards, Brian. 



More information about the Haskell-Cafe mailing list