
On Jul 22, 2008, at 6:32 PM, Brandon S. Allbery KF8NH wrote:
On Jul 22, 2008, at 13:18 , L29Ah wrote:
outStanza | (isMessage) = outMessage | (isPresence) = outPresence | (isIQ) = outIQ
Why such a style doesn't work, so I must write ugly code like that:
Because the Haskell 98 Report specifies that guards are rewritten in a specific way, which in your case produces invalid code. See http://haskell.org/onlinereport/decls.html#pattern-bindings for details.
You may mimic the syntax you wish by writing your own PF combinators, eg. by declaring outStanza = (isMessage .= outMessage .| (isPresence .= outPresence .| (isIQ .= outIQ .| ... ))) once you've defined combinators (p .= f) x = if p x then (f .Left) x else (f. Right) x and (f .| g) (Left a) = f a (f .| g) (Right b) = g b with appropriate infix priorities ( .| higher than .= ). But you still need the extra parentheses... jno
____________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe