type equality symbol

Manuel M T Chakravarty chak at cse.unsw.edu.au
Wed Dec 5 21:35:51 EST 2007

Isaac Dupree:
> Manuel M T Chakravarty wrote:
>> Simon Peyton-Jones:
>>> Nothing deep.  Just that "=" means so many things that it seemed  
>>> better to use a different notation.
>> Also, using "=" would have entailed significant changes to GHC's  
>> parser.  Type constraints are in the same syntactic category as  
>> types and types can appear as part of expressions in type  
>> annotations (such as "e::t") and on the lhs of let-bindings (such  
>> as "let x::t = e in e'").  Especially, considering the later,  
>> imagine "t" can now also contain the symbol "=" which in the  
>> grammar serves as a separator between the lhs and the rhs of a let  
>> bindings.
>> I actually did try using "=", but it got too messy.
> oh, because it doesn't require parentheses:
> f :: a ~ b => a -> b
> f = id
> and also because, it sounds like you say, current parser looks at  
> "type-class" and "type" expressions the same, so one doesn't really  
> want to distinguish them just for this.
> x :: a = b => c = x
> really is too confusing, even if I can't see any way to make it  
> ambiguous given current set of available language extensions.

For example,

   let {x :: t1 = t2 = e} in ...

Now, this is not type correct, as x cannot have a type "t1 = t2", but  
the parser cannot know that.  For the parser, a type constraint is a  
type like any other.


More information about the Glasgow-haskell-users mailing list