
On 29 dec 2013, at 18:40, Hans Höglund wrote:
On Sat, Dec 28, 2013 at 5:13 PM, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> 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] http://hackage.haskell.org/package/transformers-0.3.0.0/docs/Data-Functor-Co... 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.
Would it be as simple as adding this instance to Data.Functor.Compose:
instance (Functor m, Traversable n, Monad m, Monad n) => Monad (Compose m n)
or can anyone spot a problem with this approach?
Hans
[1]: http://web.cecs.pdx.edu/~mpj/pubs/RR-1004.pdf, page 9 [2]: http://strictlypositive.org/IdiomLite.pdf