Functor, Applicative, Monad, Foldable, Traversable instances for (, , ) a b

Jakub Daniel jakub.daniel at gmail.com
Thu Mar 30 21:52:47 UTC 2017


I know I have no say in this. But the argument against instances for (,) and other tuples seems flawed to me. It is categorically valid to view (a,-) as a functor. It is no different from 0 being an integer, yet we could end up trying to divide by 0. But do we exclude 0, because it really is a special number? (,) is a special kind of Functor/Foldable/... and people might just as well accept it. The argument that small changes to a correct code lead to code that compiles yet is not correct does not stand either, because you get exactly the same problem with other valid instances like Map etc.

Jakub

> On 30 Mar 2017, at 23:36, Bryan Richter <b at chreekat.net> wrote:
> 
>> On Thu, Mar 30, 2017 at 11:18:10PM +0200, Henning Thielemann wrote:
>> 
>>> On Thu, 30 Mar 2017, Bryan Richter wrote:
>>> 
>>> My intuition, based on observed usage in Haskell and elsewhere, is
>>> that tuples are used as anonymous product types. Thus, I am
>>> interested in the rationale for making them Functors because I feel
>>> it has denied me a common, valuable tool. I no longer feel that I
>>> should use pairs as product types. By making "(,) a" a Functor, it is
>>> no longer an anonymous product type —— it is an anonymous Reader. Are
>>> anonymous Readers really all that much more valuable than anonymous
>>> product types? I cannot conceive it. I must be missing something.
>> 
>> Pairs as functors are Writers. The function type got a Functor
>> instance that corresponds to Readers.
> 
> Oops, laziness of the bad sort on my own part. :)
> 
>> I think the only reason is that some programmers got "laziness" wrong
>> and try to use primitive types for everything instead of using (and
>> importing) dedicated types.
> 
> Well, is there anything to be done for it at this point? Is there even
> any consensus that this was, in retrospect, a poor choice?
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list