In lab the other day I was showing pattern bindings to a student and
broached a limiting case, one with no variables to be bound in the
pattern. I was surprised to find that Hugs crashed when I tried a
pattern binding at top level like this:
(2,[1,4],5) = (2,[1,4],5)
It also crashed on the simpler:
 = 
On the other hand, this turns out to be acceptable:
2 = 2
In fact, even this goes through without a hitch!
2 = 3
I'm not sure from the language definition yet whether this last
should give an "Unmatched pattern" error, but if it's intended
behavior, it does look a little odd.
Would anyone care to argue for or against allowing this?
In any case, the more structured patterns cause the latest (Sep 06)
Hugs release to crash, with "INTERNAL ERROR: compileGlobalFunction".
(GHC allows the strange "2 = 3" and handles the structured ones fine,
including even "(1,[2,3],4) = (4,[3,37],42)". I haven't checked any
Re: [Haskell-cafe] Bug in Hugs, Haskell behavior question
Derek: yes, I caught this in the language description not long after hitting "send": I had forgotten about that.
But then I anticipated the behavior Ryan shows below, where using a variable that's part of a "strange" pattern will cause an error (I didn't want to check it while driving home--cell phone user/drivers are bad enough!--so thanks, Ryan, for verifying :) ).
In any case, opinions about the behavior aside, there is a Hugs internal error here, so I hope that much is useful.
The strange cases make for interesting academic discussions, at least.
On Fri 4 Apr 08, at 6:49 pm, Derek Elkins wrote:
Top-level bindings are irrefutable, so 2 = 3 is fine, if vacuous.