
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?

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@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@haskell.org http://www.haskell.org/**mailman/listinfo/librarieshttp://www.haskell.org/mailman/listinfo/libraries

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
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@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@haskell.org http://www.haskell.org/**mailman/listinfo/librarieshttp://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

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
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
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
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@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

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@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@haskell.org http://www.haskell.org/**mailman/listinfo/librarieshttp://www.haskell.org/mailman/listinfo/libraries
participants (5)
-
Dan Burton
-
Edward Kmett
-
Henning Thielemann
-
Jake McArthur
-
Sjoerd Visscher