[Haskell-beginners] case in monadic function

Daniel Schoepe asgaroth_ at gmx.de
Fri Jan 23 10:52:39 EST 2009

Kovacs David wrote:
> Hello!
> I have a function like this: http://rafb.net/p/8E66FI29.html, starting
> with evalState. The problem is with checkPredName cause it's return type
> is SemanticError what's not a monadic value but case waiting for m a (as
> the error message sais), but if I use return to checkPredName then ofc
> the pattern match will fail. How can I fix this?
> Regards, David

You can use liftM/fmap to lift a function into a monad:
case (checkPredName pn . snd) `fmap` get of ...

More information about the Beginners mailing list