On Sun, Oct 3, 2010 at 9:40 PM, Michael Vanier <mvanie...@gmail.com> wrote:

>
> {- This doesn't work: -}
> newtype MyMonad a =
>  MyMonad ((StateT (MyData a) (Either SomeError) a))
>  deriving (Monad,
>            MonadState (MyData a),
>            MonadError SomeError,
>            Typeable)
>

This simply isn't allowed by the generalised newtype derivation machinery,
because the type variable "a" appears in one of the classes you're deriving.

In fact, I'm not sure how you're hoping for your type to actually work as a
monad. If you try using (>>=) on your type synonym that currently appears to
typecheck, you'll find that the only value that can inhabit the state
parameter is bottom. Try writing out and using a definition of (>>=) by hand
to understand your confusion.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to