2008/7/22 J.N. Oliveira <[EMAIL PROTECTED]>:
> But you still need the extra parentheses...

Not so!

infixl 0 .|
infixl 0 .|...  -- 'otherwise' construct
infix 1 .=

(.=) :: (a -> Bool) -> (a -> b) -> (a -> Maybe b)
(.|) :: (a -> Maybe b) -> (a -> Maybe b) -> (a -> Maybe b)
(.|...) :: (a -> Maybe b) -> (a -> b) -> (a -> b)
-- implementations left as exercise for the reader

outStanza = isMessage .= outMessage
         .| isPresence .= outPresence
         .| isIQ       .= outIQ
         .|...            const 42

Hooray for abusing operators!

Luke
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to