Preliminary proposal: Monoidal categories in base and proc notation support

Edward Kmett ekmett at gmail.com
Mon Sep 15 14:09:56 UTC 2014


The current categories package tries to let you reuse bifunctors of the form c * d -> e across base categories, so that e.g. Kleisli m can use (,) for its product, etc. (in general it isn't a real product for Kleisli m, but let's pretend) this means we have to adopt a 3 for 2 policy wrt the categories involved. c e -> d, c d -> e, d e -> c, but when inferring from first or second you usually only know one, but also only need one other, but can't know the third from context, since no arrow is supplied. It is underdetermined.

Hask avoids this by presupposing a single set of categories for every Bifunctor, but it is a conceit of the package that this is enough in practice, not something I know, and we pay a measurable price for this. A lot of stuff is more complex there! The current hask design, as opposed to the one I gave a talk on and the design of categories loses a lot of what powers lens and the like in exchange for this simpler story. I don't make that change lightly and I'd hesitate to make that change across the entire ecosystem. It hasn't proved it is worth the burden yet.

In exchange for this complexity it is able to find simplicity elsewhere, e.g. Bifunctor in hask is a derived concept from a Functor to a Functor category, which models the curried nature of the arguments to a Bifunctor.

My main point is there are a lot of points in the design space, and I don't think we're equipped to find a clear winner right now.

Sent from my iPad

> On Sep 15, 2014, at 3:53 PM, Sophie Taylor <sophie at traumapony.org> wrote:
> 
> Oh darn, really? That is so disappointing. Why can't it maintain inference? :\
> 
>> On 15 September 2014 23:44, Edward Kmett <ekmett at gmail.com> wrote:
>> I find PFunctor/QFunctor finer grained than is tasteful. Alas, they are necessary for inference for first/second in practice unless you require the Bifunctor to determine the category of both of its arguments. The hask package is exploring other ways to maintain inference.
>> 
>> If you try to actually use the current categories package without them, well, nothing infers.
>> 
>> Sent from my iPad
>> 
>>> On Sep 15, 2014, at 11:32 AM, Sophie Taylor <sophie at traumapony.org> wrote:
>>> 
>>> >Hi Sophie,
>>> 
>>> >In your proposal draft, I am missing the rationale part.
>>> Yeah, I'm still writing it - I definitely need to expand that a bit mor.
>>> >Do we need *all* of these classes in base in order to desugar proc? Can
>>> you demonstrate why they are needed? Or will something simpler suffice?
>>> 
>>> I think I might remove the binoidal class, and remove the PFunctor/QFunctor classes - I included them because I usually find finer grained class hierarchies to be more tasteful; but it probably would make it more frustrating to implement an arrow, for example.
>>> With SMC classes, proc notation can be desugared to remove a LOT of calls to arr, which allows more fine-grained RULES optimisations to take place, and additional work such as the ModalTypes extension in Adam Megacz Joseph's thesis to be much more straightforward.
>>> _______________________________________________
>>> ghc-devs mailing list
>>> ghc-devs at haskell.org
>>> http://www.haskell.org/mailman/listinfo/ghc-devs
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140915/833aaae2/attachment.html>


More information about the ghc-devs mailing list