[Haskell-cafe] Question on a common pattern

Donn Cave donn at avvanta.com
Tue Mar 15 16:11:15 CET 2011


Quoth Achim Schneider <barsoap at web.de>,
...
> I use 
>
>     someIO >>= f where
>       f Opt1 = ...
>
> If it's a common pattern, you can even do
>
> opts f _ _ (Opt1 x) = f x
> opts _ g _ (Opt2 x) = g x
> opts _ _ h (Opt3 x) = h x
>
> . Functions are easier to mess around with than case expressions.

I like this ... or, I would like it, if I could make it work!

I get "The last statement in a 'do' construct must be an expression",
if I don't drag the `where' clause down to the end of the `do' block
around `someIO', which of course is what we're trying to avoid with
the case expression.  I must have missed a trick with the layout?

	Donn Cave, donn at avvanta.com



More information about the Haskell-Cafe mailing list