[Haskell-cafe] Using the ContT monads for early exits of
IO ?
Christopher Done
chrisdone at googlemail.com
Fri Jun 11 10:06:57 EDT 2010
On 11 June 2010 14:40, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
>> if x then foo
>> else if y then bar
>> else if z then mu
>> else zot
>
> case () of
> _ | x -> foo
> | y -> bar
> | otherwise -> zor
>
> it's usually considered as "haskell way" of doing this
The example is merely to demonstrate how optional layout can encode
useful patterns, not to claim there aren't other ways to do it in
Haskell. For what it's worth, this solution is pretty hackish and so
not really Haskelly.
More information about the Haskell-Cafe
mailing list