[Haskell-cafe] Restricted type classes

David Menendez dave at zednenem.com
Mon Sep 6 13:33:50 EDT 2010

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.

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.

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

>> 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.

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?

Dave Menendez <dave at zednenem.com>

More information about the Haskell-Cafe mailing list