<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><pre>> On Sat, Dec 28, 2013 at 5:13 PM, Tom Ellis
> <tom-lists-haskell-cafe-2013 at <a href="http://jaguarpaw.co.uk">jaguarpaw.co.uk</a>> wrote:
> > data Wrap m n a = Wrap (m (n a))

> This is Compose [0] from traversable. It doesn't have a Monad
> instance, though...

> Erik

> [0] <a href="http://hackage.haskell.org/package/transformers-0.3.0.0/docs/Data-Functor-Compose.html">http://hackage.haskell.org/package/transformers-0.3.0.0/docs/Data-Functor-Compose.html</a>
</pre><div>According to [1], Wrap/Compose does indeed have a Monad instance terms of traverse (here called 'swap'). As far as I understand the paper includes a proof that all the Monad laws holds for such as composition, however there is no mention of transformers as the paper predates them. Personally I am not sure that the transformer composition is useful.</div><div><br></div><div>Would it be as simple as adding this instance to Data.Functor.Compose:</div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><br></span></div><div>> <span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">instance (Functor m, Traversable n, Monad m, Monad n) => Monad (Compose m n)</span></div><div><br></div><div>or can anyone spot a problem with this approach?</div><div><br></div><div>Hans</div><div><br></div><div>[1]: <a href="http://web.cecs.pdx.edu/~mpj/pubs/RR-1004.pdf">http://web.cecs.pdx.edu/~mpj/pubs/RR-1004.pdf</a>, page 9</div><div>[2]: <a href="http://strictlypositive.org/IdiomLite.pdf">http://strictlypositive.org/IdiomLite.pdf</a></div></body></html>