[Haskell-beginners] case in monadic function

Thomas Davie tom.davie at gmail.com
Fri Jan 23 09:54:30 EST 2009


On 23 Jan 2009, at 15:40, 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?

Oops, sorry, I meant monad, because this monad unfortunately doesn't  
have it's associated Applicative instance (which is much nicer to work  
with).  You can ofc create the standard applicative instance:

instance Error e => Applicative (Either e) where
   pure = return
   (<*>) = ap

Bob


More information about the Beginners mailing list