Henning Thielemann | 26 Aug 18:59 2013
Picon

Pointed and Traversable

There was a lot of discussion about separating "pure" from Applicative 
and putting it into a Pointed class. If I remember correctly, the main 
counter argument was that 'pure' alone does not satisfy interesting 
laws. There are only such laws in connection with the Applicative class.

Now, in some situations I liked to have a generalized unfoldr. I can 
build this from "pure" and "sequenceA" using the State monad:

unfoldr :: (Pointed t, Traversable t) => (s -> (a, s)) -> s -> t a
unfoldr = evalState . sequenceA . pure . state

One could state a law like:

    traverse f (pure a) == traverse id (pure (f a))

Would this justify to move "pure" into a new Pointed class?
Edward Kmett | 26 Aug 19:16 2013
Picon

Re: Pointed and Traversable

There are several uses of Pointed as a separate beast from Applicative. In particular it comes up when we talk about "affine traversals", and would let us refine the type hierarchy of lens, so you'd think I'd be for it. 

However, to move it into its own class would require literally everyone who currently has an Applicative instance to clutter their code with CPPs.

Even as the author of the Pointed class, I personally find that the benefit of the change doesn't warrant the impact of the change.

-Edward


On Mon, Aug 26, 2013 at 12:59 PM, Henning Thielemann <schlepptop <at> henning-thielemann.de> wrote:
There was a lot of discussion about separating "pure" from Applicative and putting it into a Pointed class. If I remember correctly, the main counter argument was that 'pure' alone does not satisfy interesting laws. There are only such laws in connection with the Applicative class.

Now, in some situations I liked to have a generalized unfoldr. I can build this from "pure" and "sequenceA" using the State monad:

unfoldr :: (Pointed t, Traversable t) => (s -> (a, s)) -> s -> t a
unfoldr = evalState . sequenceA . pure . state

One could state a law like:

   traverse f (pure a) == traverse id (pure (f a))

Would this justify to move "pure" into a new Pointed class?

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Dan Burton | 26 Aug 19:54 2013
Picon

Re: Pointed and Traversable

What are some example data types which have a "pure" which obeys this law, but no corresponding law-abiding "ap"? The only compelling reason to split it off is if the separation of abstractions will give us the power to reuse code which was previously not as reusable.

-- Dan Burton


On Mon, Aug 26, 2013 at 10:16 AM, Edward Kmett <ekmett <at> gmail.com> wrote:
There are several uses of Pointed as a separate beast from Applicative. In particular it comes up when we talk about "affine traversals", and would let us refine the type hierarchy of lens, so you'd think I'd be for it. 

However, to move it into its own class would require literally everyone who currently has an Applicative instance to clutter their code with CPPs.

Even as the author of the Pointed class, I personally find that the benefit of the change doesn't warrant the impact of the change.

-Edward


On Mon, Aug 26, 2013 at 12:59 PM, Henning Thielemann <schlepptop <at> henning-thielemann.de> wrote:
There was a lot of discussion about separating "pure" from Applicative and putting it into a Pointed class. If I remember correctly, the main counter argument was that 'pure' alone does not satisfy interesting laws. There are only such laws in connection with the Applicative class.

Now, in some situations I liked to have a generalized unfoldr. I can build this from "pure" and "sequenceA" using the State monad:

unfoldr :: (Pointed t, Traversable t) => (s -> (a, s)) -> s -> t a
unfoldr = evalState . sequenceA . pure . state

One could state a law like:

   traverse f (pure a) == traverse id (pure (f a))

Would this justify to move "pure" into a new Pointed class?

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Sjoerd Visscher | 27 Aug 01:32 2013

Re: Pointed and Traversable

A lot of sum types fall in this category. There's no general way to implement "ap" for coproducts, but "pure" is easy, just pick one. The problem with this law is that it doesn't really help you pick one.

What the law says is that "pure a" should not contain any other a's than the one given. But pure cannot get an "a" from somewhere else because of parametricity, so the law always holds.

Sjoerd
 
On Aug 26, 2013, at 7:54 PM, Dan Burton <danburton.email <at> gmail.com> wrote:

What are some example data types which have a "pure" which obeys this law, but no corresponding law-abiding "ap"? The only compelling reason to split it off is if the separation of abstractions will give us the power to reuse code which was previously not as reusable.

-- Dan Burton


On Mon, Aug 26, 2013 at 10:16 AM, Edward Kmett <ekmett <at> gmail.com> wrote:
There are several uses of Pointed as a separate beast from Applicative. In particular it comes up when we talk about "affine traversals", and would let us refine the type hierarchy of lens, so you'd think I'd be for it. 

However, to move it into its own class would require literally everyone who currently has an Applicative instance to clutter their code with CPPs.

Even as the author of the Pointed class, I personally find that the benefit of the change doesn't warrant the impact of the change.

-Edward


On Mon, Aug 26, 2013 at 12:59 PM, Henning Thielemann <schlepptop <at> henning-thielemann.de> wrote:
There was a lot of discussion about separating "pure" from Applicative and putting it into a Pointed class. If I remember correctly, the main counter argument was that 'pure' alone does not satisfy interesting laws. There are only such laws in connection with the Applicative class.

Now, in some situations I liked to have a generalized unfoldr. I can build this from "pure" and "sequenceA" using the State monad:

unfoldr :: (Pointed t, Traversable t) => (s -> (a, s)) -> s -> t a
unfoldr = evalState . sequenceA . pure . state

One could state a law like:

   traverse f (pure a) == traverse id (pure (f a))

Would this justify to move "pure" into a new Pointed class?

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Jake McArthur | 31 Aug 00:14 2013
Picon

Re: Pointed and Traversable

Are we even sure this law isn't already guaranteed by parametricity and perhaps the existing laws of the other type classes involved? I for one can't think of a pointed traversable which doesn't already obey this law.

On Aug 26, 2013 1:02 PM, "Henning Thielemann" <schlepptop <at> henning-thielemann.de> wrote:
There was a lot of discussion about separating "pure" from Applicative and putting it into a Pointed class. If I remember correctly, the main counter argument was that 'pure' alone does not satisfy interesting laws. There are only such laws in connection with the Applicative class.

Now, in some situations I liked to have a generalized unfoldr. I can build this from "pure" and "sequenceA" using the State monad:

unfoldr :: (Pointed t, Traversable t) => (s -> (a, s)) -> s -> t a
unfoldr = evalState . sequenceA . pure . state

One could state a law like:

   traverse f (pure a) == traverse id (pure (f a))

Would this justify to move "pure" into a new Pointed class?

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

Gmane