It seems really hard to solve this, since the type checker works before instance selection has had a chance to do anything.<br><br>Instead of looking at the instance declaration, look at the use site:<br><br> lift x<br><br>
expects the argument to have type<br><br> x :: t m a<br><br>for some t :: (* -> *) -> * -> *, m :: * -> *, and a :: *; it's not until t is known that we can do instance selection, and in your case, EitherT M A B doesn't have the required form and so is a type error already.<br>
<br>I think the best answer is sadly to just have to have a (kind-polymorphic!) newtype flip and deal with it.<br><br>I can imagine there being some way to (ab)use kind polymorphism to redefine MonadTrans in a way that allows the 'm' argument to appear in more places in the target type, but I'm not clever enough to come up with a proposal for how to do so.<br>
<br> -- ryan<br><br><br><div class="gmail_quote">On Mon, Aug 13, 2012 at 4:38 PM, Tony Morris <span dir="ltr"><<a href="mailto:tonymorris@gmail.com" target="_blank">tonymorris@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a data-type that is similar to EitherT, however, I have ordered<br>
the type variables like so:<br>
<br>
data EitherT (f :: * -> *) (a :: *) (b :: *) = ...<br>
<br>
This allows me to declare some desirable instances:<br>
<br>
instance Functor f => Bifunctor (EitherT f)<br>
instance Foldable f => Bifoldable (EitherT f)<br>
instance Traversable f => Bitraversable (EitherT f)<br>
<br>
However, I am unable to declare a MonadTrans instance:<br>
<br>
instance MonadTrans (EitherT a) -- kind error<br>
<br>
I looked at Control.Compose.Flip to resolve this, but it does not appear<br>
to be kind-polymorphic.<br>
<a href="http://hackage.haskell.org/packages/archive/TypeCompose/0.9.1/doc/html/src/Control-Compose.html#Flip" target="_blank">http://hackage.haskell.org/packages/archive/TypeCompose/0.9.1/doc/html/src/Control-Compose.html#Flip</a><br>
<br>
I was wondering if there are any well-developed techniques to deal with<br>
this? Of course, I could just write my own Flip with the appropriate<br>
kinds and be done with it. Maybe there is a more suitable way?<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Tony Morris<br>
<a href="http://tmorris.net/" target="_blank">http://tmorris.net/</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br>