> if I write
> 
> (a &&& b) x = a x && b x
> 
> hugs accepts it, but ghc rejects it.  I think that ghc is correct in
> that the report only allows ...

Yes, GHC adheres to the report more closely than Hugs.

However, the fact that you typed it in suggests that it's a reasonable
thing for Standard Haskell to support.   It's a regular source of bug
reports on both mailing lists.

In an ideal world, the Haskell grammar would be simplified by merging
the rules for pattern syntax with those for expression syntax.

Of course, then the syntax would "allow" expressions like this:

  x@(l,r)

and patterns like this:

  (foo bar)
  [ x | x <- xs ]

We'd have to shift the burden of detecting these problems to the static
semantics (which is how things are done in Gofer and Hugs).

Gains:
o a slightly more expressive language
o a simpler grammar 
  About 20 rules vanish instantly.
  Also, I think it's easier to say "patterns are just like expressions
  except they can't contain list comprehensions, function call or ..."
  and expressions are not allowed to contain "@".
o parsing becomes simpler
  eg wWhen parsing a qualifier in a let comprehension, you can't tell
   if the qualifier is a guard or a pattern binding until you find 
   <- or , or ].  That's why Mark implemented things the way he did.

Losses:
o some syntax errors are detected marginally later
  I don't recall anyone ever complaining when Hugs does this.
o muddies the waters between syntax and static semantics
  - but I don't think the waters are that clear to start with.

-- 
Alastair Reid              Yale Haskell Project Hacker
[EMAIL PROTECTED]  http://WWW.CS.Yale.EDU/homes/reid-alastair/



Reply via email to