On Tue, Jul 22, 2008 at 10:27 AM, Neil Mitchell <[EMAIL PROTECTED]> wrote: > Hi > >> Why such a style doesn't work, so I must write ugly code like that: >> >> outStanza a | (isMessage a) = outMessage a >> | (isPresence a) = outPresence a >> | (isIQ a) = outIQ a > > You can make it slightly prettier, since the brackets are not necessary: > > outStanza a | isMessage a = outMessage a > | isPresence a = outPresence a > | isIQ a = outIQ a
Also, if it really is in that format, maybe you can write something like: switch v pairs = maybe (error "no match") ($v) (lookupWith ($v) pairs) And then you can write the list point-free, though you don't get the nice guard syntax. I guess lookupWith must be one of my local functions, but it's easy to write too. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
