John Lato jwlato at gmail.com
Mon Sep 6 15:18:30 EDT 2010

```On Mon, Sep 6, 2010 at 12:33 PM, David Menendez <dave at zednenem.com> wrote:

> On Mon, Sep 6, 2010 at 7:51 AM, John Lato <jwlato at gmail.com> wrote:
> > On Sun, Sep 5, 2010 at 7:18 PM, David Menendez <dave at zednenem.com>
> wrote:
> >>
> >> On Sun, Sep 5, 2010 at 8:40 AM, John Lato <jwlato at gmail.com> wrote:
> >> >
> >> >
> >> > On Sat, Sep 4, 2010 at 12:34 PM, David Menendez <dave at zednenem.com>
> >> > wrote:
> >> >>
> >> >> On Fri, Sep 3, 2010 at 8:23 AM, John Lato <jwlato at gmail.com> wrote:
> >> >>
> >> >> > +1 for using the proper constraints, and especially for bringing
> over
> >> >> > Pointed (and anything else that applies).
> >> >>
> >> >> What's the argument for Pointed? Are there many types which are
> >> >> instances of Pointed but not Applicative? Are there many algorithms
> >> >> which require Pointed but not Applicative?
> >> >
> >> > Having Pointed is categorically the right thing to do, which is why I
> >> > argue
> >> > for its inclusion.
> >>
> >> Why is it categorically the right thing to do?
> >
> > Because it's the proper abstraction underlying Applicative and Monad, as
> far
> > as I understand category theory.
>
> What makes it "the proper" abstraction? Applicative Functors have
> three parts: the functor, pure, and <*>, along with some equations
> they need to satisfy. We know Functor by itself is useful, but what
> makes Functor+pure better than Functor+<*> or pure+<*> or any other
> subset? The fact that it has a name doesn't make it useful for
> programming; category theory has names for all sorts of things that
> don't come up very often.
>

I'm arguing in favor of pure by itself, not just pure+Functor.  Ivan's
already given one example of a structure that only meets the point criteria:
a Bloom filter.

Regarding Applicative Functors somewhat off-topic, you can define fmap
strictly in terms of pure+<*>.  It's interesting that they're somewhat
parallel to non-applicative Functors in that the Functor instance isn't
necessary, it's the pointed and <*> that are.  Once you have those you get
either.

Can you give an example of a Functor that doesn't have pure?  I think it's
Pointed Functors which are useful; not Functor by itself.

>
> For that matter, can you even describe what pure is intended to do
> without reference to <*> or join? You can say that it's a natural
> transformation from Id to f, but so is \x -> [x,x]. You can say it
> "contains one copy" of the argument, but that doesn't work for the
> Const functor or the infinite stream functor, among others.
>

Broadly, I agree that pure should behave in a manner consistent with the
Applicative or Monad instance if they exist.  In the context of a
collections interface though, pure should be identical to singleton, which
should guide the choice of Applicative or Monad if there is one.

> I notice no one has given any algorithms that operate on arbitrary
> pointed functors.
>

Ivan gave one useful data structure for which point by itself has meaning
but Applicative doesn't.  Also Point would be a useful base class for a
non-empty data API (for which Monoid is unusable).

>
> >> When Conor McBride was promoting the use of Applicative (then called
> >> Idiom), he provided several instances and algorithms showing that it
> >> was a useful generalization of Monad, and it still took several years
> >> and a few papers[1] before Applicative found its way into the standard
> >> library.
> >>
> >> In other words, we didn't add Applicative and then discover
> >> Traversable later. Traversable was a big part of the argument for why
> >> Applicative is useful.
> >
> > I take this in favor of my point.  Applicative wasn't considered useful,
> so
> > it wasn't included.  Then Conor McBride shows that it is useful, but at
> that
> > point it was too late and now we're stuck with pure, return, ap, liftA2,
> > liftM2, etc.
>
> I think that has more to do with Haskell 98 compatibility. We broke
> Category out of Arrow not too long ago.
>

What was Category doing in Arrow to begin with?  Wouldn't it have been
easier if they had been separate from the start?  Why do you think we should
do the same thing now?

>
> Furthermore, you didn't address my point: Applicative is *useful*. We
> have algorithms that are parameterized by arbitrary applicative
> functors. We have multiple examples of useful non-monad applicative
> functors. What are pointed functors good for?
>

Again, I don't care so much for pointed functors as for Pointed, and I've
given two examples of where it would be useful.  What's wrong with breaking
Pointed off?  All it requires is one instance with one method which you
would have written anyway.  That's one extra LOC, and if you base Monad and
Applicative off of it there's zero change.  Also a clear separation of
concerns is better than conflating meanings together.

John
-------------- next part --------------
An HTML attachment was scrubbed...