[Haskell-cafe] Point-free style in guards

Henning Thielemann lemming at henning-thielemann.de
Thu Jul 31 19:37:12 EDT 2008

On Tue, 22 Jul 2008, L29Ah wrote:

> outStanza | (isMessage) = outMessage
>             | (isPresence) = outPresence
>             | (isIQ) = outIQ
> 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
> so, guards can't be useful in point-free function definitions in any way

It's sad that syntactic sugar makes people want even more syntactic sugar
(some people thus call it syntactic heroin).

You can easily achieve the wanted effect by a function like 'select'
 and that way you can also avoid guards in many cases.

More information about the Haskell-Cafe mailing list