[Haskell-cafe] Problem with monad transformer stack

Christopher Done chrisdone at googlemail.com
Sun Oct 3 22:03:07 EDT 2010


On 4 October 2010 03:40, Michael Vanier <mvanier42 at gmail.com> wrote:
> newtype MyMonad a =
>  MyMonad ((StateT (MyData a) (Either SomeError) a))
>  deriving (Monad,
>            MonadState (MyData a),
>            MonadError SomeError,
>            Typeable)

I think it's the `a'. I think it needs to be a concrete type. E.g. the
following is OK:

newtype MyMonad a =
 MyMonad ((StateT (MyData ()) (Either SomeError) a))
 deriving (Monad,
           MonadState (MyData ()),
           MonadError SomeError,
           Typeable)

But

newtype MyMonad a =
 MyMonad ((StateT (MyData ()) (Either SomeError) [a]))
 deriving (Monad,
           MonadState (MyData ()),
           MonadError SomeError,
           Typeable)

is not. This reminds me of the restriction that impredicative types
remove, but I don't think it's related.

> These error messages mean nothing to me.  What's going on?  Can the more
> specific code be made to work?  This is with ghc 6.12.3.

It seems like eta-reducing `X' or `x' is "enough", but Foo x,, i.e. a
parametrized type with a type variable isn't "enough". I think that's
what's going on, but I don't know why.


More information about the Haskell-Cafe mailing list