Pointed and Traversable

Sjoerd Visscher sjoerd at w3future.com
Tue Aug 27 01:32:07 CEST 2013


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130827/f70b616f/attachment.htm>


More information about the Libraries mailing list