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

Vladislav Zavialov vlad.z.4096 at gmail.com
Thu Mar 30 22:00:47 UTC 2017


We can have an instance that generates a type error:

instance TypeError (Text "Functor for tuples is prohibited") => Functor ((,) a)

and similarly for Foldable, Traversable, etc. But at this point it's
too late to make this change, so +1 to the proposal.

On Fri, Mar 31, 2017 at 12:53 AM, Theodore Lief Gannon <tanuki at gmail.com> wrote:
> Two bits from the peanut gallery:
>
> We have an open world of universal instances. The question is not whether
> it's convenient to have these instances. It's whether there's any likelihood
> of someone deciding to define them elsewhere if they're not in base. Because
> then they exist anyway, and without nearly as much discussion and
> refinement.
>
> Yes, it's an unfortunate situation. Yes, "length" is a bad name. But the
> realities of the Haskell ecosystem dictate that when a single lawful
> instance of a base typeclass exists for a base data type, implementing it is
> pretty much mandatory.
>
> On Thu, Mar 30, 2017 at 2:36 PM, 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
>>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


More information about the Libraries mailing list