
Thomas Davie
Just foo = undefined
The haskell syntax states:
decl -> gendecl | (funlhs | pat0) rhs
where, gendecl covers type definitions, funlhs covers functions (and must start with a lower case character), and pat0 covers 0 arity patterns.
The notation pat_0 does not mean zero-arity, but zero-fixity. Thus, since any pat_i can be a pat_i+1, and pat_10 -> apat | gcon apat_1 ... apat_k the given declaration is syntactically valid, even though it is certainly unusual. hat-trans is generating bad code for this, because the pattern binding is at the toplevel. If the pattern binding were in a let or where clause, the generated code is different. When not at the toplevel, the parent, p, of the binding is always a variable passed in. But at the toplevel, there is no static parent, so hat-trans has wrongly substituted T.mkRoot (which explicitly represents no parent), in both the generated pattern and the generated expression: gx px T.mkRoot = T.constUse px T.mkRoot sx -- incorrect vs. gx px p = T.constUse px p sx -- correct I think the attached patch for hat-trans should fix the problem (but would like someone to confirm this is not going to break anything else, before I will commit it to CVS). Regards, Malcolm