[Haskell-cafe] Question on a common pattern

Achim Schneider barsoap at web.de
Tue Mar 15 13:27:08 CET 2011


tsuraan <tsuraan at gmail.com> wrote:
> Is there a more concise way to do this?

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.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.





More information about the Haskell-Cafe mailing list