[Haskell-cafe] Re: nested maybes
J. Garrett Morris
trevion at gmail.com
Mon Feb 5 09:55:26 EST 2007
On 2/5/07, Yitzchak Gale <gale at sefer.org> wrote:
> J. Garrett Morris wrote:
> > Mainly to keep the type error messages simpler.
>
> There are two ways to get around that problem:
>
> 1. Make your functions polymorphic, using
> MonadState, MonadError, etc. Each function
> mentions only the capabilities that it needs,
> without having the whole monad stack in its type.
Again, from the earlier example, I'm not sure how typing:
apply :: (MonadCont m, MonadState Blargh m, MonadError Fzzt m, MonadIO m) =>
Handle -> Attribute a -> m a
is simpler than
apply :: Handle -> Attribute a -> m a
especially when almost every function in the project would have
required the same constraint list.
> 2. Use a type alias for the monad stack.
At least as of 6.4.2, GHC printed the expanded types, not the aliases,
in error messages.
> (There are other big advantages of both of these.)
Those being?
/g
--
It is myself I have never met, whose face is pasted on the underside of my mind.
More information about the Haskell-Cafe
mailing list