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:
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