Join a transformer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Join a transformer

Michael Snoyman
I'm wondering if this pattern exists and has a name. We have the concept of joining a Monad:

join :: Monad m => m (m a) -> ma

How about joining a monad transformer?

joinT :: (Monad m, MonadTrans t) => t (t m) a -> t m a

I believe implementing this in terms of MonadTransControl[1] might be possible, but I was wondering if there's an already existing idiom for this.

Michael


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Join a transformer

Ross Paterson-2
On Thu, Mar 14, 2013 at 05:24:23AM +0200, Michael Snoyman wrote:
>    I'm wondering if this pattern exists and has a name. We have the
>    concept of joining a Monad:
>    join :: Monad m => m (m a) -> ma
>    How about joining a monad transformer?
>    joinT :: (Monad m, MonadTrans t) => t (t m) a -> t m a

This is a monad in the category of monads.  Moggi discusses them in
"An Abstract View of Programming Languages", including which transformers
have joinT.  I was thinking of adding the class to the transformers package.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Join a transformer

Hiromi ISHII
Hi there,

Gabriel's `mmorph` library [1] provides such abstraction, i.e.
`MMonad` type-class and `squash` function.

[1]: http://hackage.haskell.org/package/mmorph

> On 2018/04/09 21:45, Ross Paterson <[hidden email]> wrote:
>
> On Thu, Mar 14, 2013 at 05:24:23AM +0200, Michael Snoyman wrote:
>>   I'm wondering if this pattern exists and has a name. We have the
>>   concept of joining a Monad:
>>   join :: Monad m => m (m a) -> ma
>>   How about joining a monad transformer?
>>   joinT :: (Monad m, MonadTrans t) => t (t m) a -> t m a
>
> This is a monad in the category of monads.  Moggi discusses them in
> "An Abstract View of Programming Languages", including which transformers
> have joinT.  I was thinking of adding the class to the transformers package.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-- Hiromi ISHII
[hidden email]
Doctoral program in Mathematics,
University of Tsukuba


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (541 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Join a transformer

Daniel Díaz Casanueva
In reply to this post by Ross Paterson-2
+1 on adding this to transformers.

2018-04-09 14:45 GMT+02:00 Ross Paterson <[hidden email]>:
On Thu, Mar 14, 2013 at 05:24:23AM +0200, Michael Snoyman wrote:
>    I'm wondering if this pattern exists and has a name. We have the
>    concept of joining a Monad:
>    join :: Monad m => m (m a) -> ma
>    How about joining a monad transformer?
>    joinT :: (Monad m, MonadTrans t) => t (t m) a -> t m a

This is a monad in the category of monads.  Moggi discusses them in
"An Abstract View of Programming Languages", including which transformers
have joinT.  I was thinking of adding the class to the transformers package.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Join a transformer

David Feuer
If something like MMonad gets added to transformers, then its MFunctor version should really be double-ended to work with things like the final version of FreeT.

On Mon, Apr 9, 2018, 9:41 AM Daniel Díaz Casanueva <[hidden email]> wrote:
+1 on adding this to transformers.

2018-04-09 14:45 GMT+02:00 Ross Paterson <[hidden email]>:
On Thu, Mar 14, 2013 at 05:24:23AM +0200, Michael Snoyman wrote:
>    I'm wondering if this pattern exists and has a name. We have the
>    concept of joining a Monad:
>    join :: Monad m => m (m a) -> ma
>    How about joining a monad transformer?
>    joinT :: (Monad m, MonadTrans t) => t (t m) a -> t m a

This is a monad in the category of monads.  Moggi discusses them in
"An Abstract View of Programming Languages", including which transformers
have joinT.  I was thinking of adding the class to the transformers package.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Join a transformer

Ross Paterson-2
On Wed, Apr 11, 2018 at 11:17:54AM +0000, David Feuer wrote:
>    If something like MMonad gets added to transformers, then its MFunctor
>    version should really be double-ended to work with things like the
>    final version of FreeT.

Since transformers is targeted at standard Haskell, it wouldn't be able
to define MFunctor or embed.  It would have to be something like

class (MonadTrans t) => MonadMonad t where
    joinT :: Monad m => t (t m) a -> t m a
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.