Differences in pattern matching syntax?

Simon Peyton-Jones simonpj at microsoft.com
Fri Jan 16 04:04:17 EST 2009


| I hardly use any let expressions (shame on me??) and I am not very familiar
| with them. But I figured out you might have mistaken, so I changed the bit
| to:
|    antecedent :: Rule -> Expression
|    antecedent r = case r of
|                    Ru{} -> if (rrsrt r == AlwaysExpr)  then error ("(Module
| ADLdataDef:) illegal call to antecedent of rule "++show r)
|                                                                    else
| rrant r
|                    Sg{} -> antecedent (srsig r)
|                    Gc{} -> let x = grspe r in r `seq` Tm x
|                    Fr{} -> frcmp r

Indeed I was wrong, as others saw too.  But in any case, I now realise that adding the `seq` makes the function stricter than Alternative 2, which your application presumably doesn't like.  (Hence <<loop>>, I assume.)

Try this instead, which should make it more like Alternative 2:

        Gc{} -> case r of { GC{ grspe = x } -> Tm x }

My guess is that will behave like Alternative 2.

Simon


More information about the Glasgow-haskell-users mailing list