Proposal: Add gtraverse to Data.Data

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

Proposal: Add gtraverse to Data.Data

Edward Kmett-2
Data.Data provides an gmapM as an analogue to mapM but not one to traverse.

The following definition from lens fills in this gap, but it probably belongs in Data.Data alongside its kin. 

gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d) -> a -> f a
gtraverse f = gfoldl (\x y -> x <*> f y) pure

Discussion period: 2 weeks
-Edward Kmett

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

Re: Proposal: Add gtraverse to Data.Data

Roman Cheplyaka-2
+1. I also blogged about it before:

http://ro-che.info/articles/2013-03-11-generalizing-gfoldl.html
http://ro-che.info/articles/2013-03-29-gtraverse-vs-gfoldl.html

* Edward Kmett <[hidden email]> [2013-08-15 19:21:39-0400]

> Data.Data provides an gmapM as an analogue to mapM but not one to traverse.
>
>
> The following definition from lens fills in this gap, but it probably
> belongs in Data.Data alongside its kin.
>
>
> gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d)
> -> a -> f a
>
> gtraverse f = gfoldl (\x y -> x <*> f y) pure
>
>
> Discussion period: 2 weeks
>
> -Edward Kmett

> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries


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

Re: Proposal: Add gtraverse to Data.Data

José Pedro Magalhães
In reply to this post by Edward Kmett-2
+1

Pedro


On Fri, Aug 16, 2013 at 1:21 AM, Edward Kmett <[hidden email]> wrote:
Data.Data provides an gmapM as an analogue to mapM but not one to traverse.

The following definition from lens fills in this gap, but it probably belongs in Data.Data alongside its kin. 

gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d) -> a -> f a
gtraverse f = gfoldl (\x y -> x <*> f y) pure

Discussion period: 2 weeks

-Edward Kmett

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries