Quantcast

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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
67 messages Options
1234
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Fumiaki Kinoshita
It's surprising that they are missing (forgive me, I'm not here to make people grumpy).

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Carter Schonwald
Plus one from me 

On Mar 23, 2017 6:54 AM, "Fumiaki Kinoshita" <[hidden email]> wrote:
It's surprising that they are missing (forgive me, I'm not here to make people grumpy).

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Ivan Lazar Miljenovic
+1, for all the other tuples as well.

On 30 March 2017 at 23:30, Carter Schonwald <[hidden email]> wrote:

> Plus one from me
>
> On Mar 23, 2017 6:54 AM, "Fumiaki Kinoshita" <[hidden email]> wrote:
>>
>> It's surprising that they are missing (forgive me, I'm not here to make
>> people grumpy).
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>



--
Ivan Lazar Miljenovic
[hidden email]
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Tony Morris
+1 it's 2017, hurry up.

On Thu, Mar 30, 2017 at 10:51 PM, Ivan Lazar Miljenovic <[hidden email]> wrote:
+1, for all the other tuples as well.

On 30 March 2017 at 23:30, Carter Schonwald <[hidden email]> wrote:
> Plus one from me
>
> On Mar 23, 2017 6:54 AM, "Fumiaki Kinoshita" <[hidden email]> wrote:
>>
>> It's surprising that they are missing (forgive me, I'm not here to make
>> people grumpy).
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>



--
Ivan Lazar Miljenovic
[hidden email]
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andreas Abel-2
I am on a highway to hell...

On 30.03.2017 15:16, Tony Morris wrote:

> +1 it's 2017, hurry up.
>
> On Thu, Mar 30, 2017 at 10:51 PM, Ivan Lazar Miljenovic
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     +1, for all the other tuples as well.
>
>     On 30 March 2017 at 23:30, Carter Schonwald
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     > Plus one from me
>     >
>     > On Mar 23, 2017 6:54 AM, "Fumiaki Kinoshita" <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     >>
>     >> It's surprising that they are missing (forgive me, I'm not here
>     to make
>     >> people grumpy).
>     >>
>     >> _______________________________________________
>     >> Libraries mailing list
>     >> [hidden email] <mailto:[hidden email]>
>     >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>     <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
>     >>
>     >
>     > _______________________________________________
>     > Libraries mailing list
>     > [hidden email] <mailto:[hidden email]>
>     > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>     <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
>     >
>
>
>
>     --
>     Ivan Lazar Miljenovic
>     [hidden email] <mailto:[hidden email]>
>     http://IvanMiljenovic.wordpress.com
>     <http://IvanMiljenovic.wordpress.com>
>     _______________________________________________
>     Libraries mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>     <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
>
>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


--
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

[hidden email]
http://www.cse.chalmers.se/~abela/
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Henning Thielemann
In reply to this post by Fumiaki Kinoshita

On Thu, 23 Mar 2017, Fumiaki Kinoshita wrote:

> It's surprising that they are missing (forgive me, I'm not here to make people grumpy).

I am not surprised because it was discussed at length a year before. I
still think all these instances on pairs, triples and other tuples are
more dangerous than helpful. It is so easy and much more expressive to
define custom data types for your particular application. Actually, I am
still actively using only GHC up to GHC-7.8.4, because starting with
GHC-7.10.3 the slogan "if it can be compiled, it is certainly correct"
cannot be reasonably claimed anymore (length(a,b)==1, maximum(2,1)==1 etc.
are just not sane). And it seems that adding damage to the libraries is
done at a much faster pace than adding compiler features to make them less
dangerous (like user-configurable warnings about dangerous instances).
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Nathan Bouscal
The argument that people should define custom data types rather than using triples doesn't have any bearing on whether triples should implement these type classes. That argument would imply that whether the type classes are implemented doesn't matter, because if you're complaining about getting unexpected results the response is "use a custom data type", and similarly if you're complaining about the lack of a type class instance the response is "use a custom data type". So, even though it's true that people generally should use custom data types instead of triples, it's irrelevant to the discussion.

+1 on the proposal. Consistency is good.

On Thu, Mar 30, 2017 at 11:30 AM, Henning Thielemann <[hidden email]> wrote:

On Thu, 23 Mar 2017, Fumiaki Kinoshita wrote:

It's surprising that they are missing (forgive me, I'm not here to make people grumpy).

I am not surprised because it was discussed at length a year before. I still think all these instances on pairs, triples and other tuples are more dangerous than helpful. It is so easy and much more expressive to define custom data types for your particular application. Actually, I am still actively using only GHC up to GHC-7.8.4, because starting with GHC-7.10.3 the slogan "if it can be compiled, it is certainly correct" cannot be reasonably claimed anymore (length(a,b)==1, maximum(2,1)==1 etc. are just not sane). And it seems that adding damage to the libraries is done at a much faster pace than adding compiler features to make them less dangerous (like user-configurable warnings about dangerous instances).

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Henning Thielemann

On Thu, 30 Mar 2017, Nathan Bouscal wrote:

> The argument that people should define custom data types rather than
> using triples doesn't have any bearing on whether triples should
> implement these type classes. That argument would imply that whether the
> type classes are implemented doesn't matter, because if you're
> complaining about getting unexpected results the response is "use a
> custom data type",

I don't want unexpected results, I want clear type errors. That's only
possible with missing type instances.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

amindfv
-1 for reasons covered in other discussions.

Tom


> El 30 mar 2017, a las 15:06, Henning Thielemann <[hidden email]> escribió:
>
>
>> On Thu, 30 Mar 2017, Nathan Bouscal wrote:
>>
>> The argument that people should define custom data types rather than using triples doesn't have any bearing on whether triples should implement these type classes. That argument would imply that whether the type classes are implemented doesn't matter, because if you're complaining about getting unexpected results the response is "use a custom data type",
>
> I don't want unexpected results, I want clear type errors. That's only possible with missing type instances.
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Bryan Richter-2
In reply to this post by Henning Thielemann
On Thu, Mar 30, 2017 at 08:30:32PM +0200, Henning Thielemann wrote:

> On Thu, 23 Mar 2017, Fumiaki Kinoshita wrote:
>
> >It's surprising that they are missing (forgive me, I'm not here to
> >make people grumpy).
>
> I am not surprised because it was discussed at length a year before. I
> still think all these instances on pairs, triples and other tuples are
> more dangerous than helpful. It is so easy and much more expressive to
> define custom data types for your particular application.

I can't help but feel the same way. I find it detrimental that pairs have
a Functor instance. I don't care that 'length' is a member of Foldable,
or that anything that is a Functor can/should be Foldable —— I just
don't know why pairs ever got to Functor. I fear this was an ancient
decision... no?

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.

And certainly somebody might argue, "Just keep using them as product
types. Nothing has changed." But of course something has changed. My
product now has a sharp edge. There is some extra information I have to
hold in my head: "Don't put this in a Functor context and expect to be
able to follow the compiler errors!"

If I wanted to hold extra information in my head, surely I would go back
to using Perl.

I fear that pairs became Functors a long, long time ago, and now we're
stuck with it. Is that true? If so, I believe that crucial fact should
preface any argument about 'length', and hopefully we could agree the
root cause of `length (a,b) == 1` —— if it is to be considered a
problem —— is the fact that `fmap f (a,b) == (a, f b)`.

For whatever my vote is worth as somebody posting to this list for the
first time,

-1.

Thanks,

-Bryan

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Henning Thielemann

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. Functions as Readers (and Either as exception
monad) must have happened in the GHC-6 version range and Pairs as Writers
is quite recent and happened together with moving Monoid to Prelude
(because Writers need Monoid for the left pair element).

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.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Bryan Richter-2
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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Henning Thielemann

On Thu, 30 Mar 2017, Bryan Richter wrote:

> On Thu, Mar 30, 2017 at 11:18:10PM +0200, Henning Thielemann wrote:
>>
>> 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?

The community was and is pretty divided, I think. My suggested compromise
is to get compiler warnings if you use certain instances (by accident).
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Jakub Daniel
In reply to this post by Bryan Richter-2
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 <[hidden email]> 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
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Theodore Lief Gannon
In reply to this post by Bryan Richter-2
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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Theodore Lief Gannon
In reply to this post by Henning Thielemann
re: compiler warnings -- I saw this on reddit a little while back, but I don't think I've seen it in this thread? Worth posting in case anyone missed it: http://blog.ezyang.com/2017/03

On Thu, Mar 30, 2017 at 2:49 PM, Henning Thielemann <[hidden email]> wrote:

On Thu, 30 Mar 2017, Bryan Richter wrote:

On Thu, Mar 30, 2017 at 11:18:10PM +0200, Henning Thielemann wrote:

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?

The community was and is pretty divided, I think. My suggested compromise is to get compiler warnings if you use certain instances (by accident).

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Nathan Bouscal
In reply to this post by Bryan Richter-2
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?
 
No, there isn't a consensus in either direction. As I understand it, the basic argument for pairs being functors is that there is a single possible way of making them functors, and that that instance is useful sometimes, so someone is going to define it anyway. One of the more convincing (to me) ways it (and other similar instances) is useful is as a building block for other types; Free and Cofree were mentioned last time this was discussed. The argument isn't so much about any specific instance being valuable, but rather about the health of the ecosystem of algebraic structures. Having arbitrary gaps in instance coverage because some people don't like those specific instances really doesn't seem reasonable.

I also don't agree with your description of it as an "anonymous Reader". The Functor instance is the only possible Functor instance for the type; "Reader" is an additional semantic description of one way of thinking about that instance.

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Nathan Bouscal
Oops, same correction, Writer rather than Reader. A reflection of how little I think of them in terms of those semantics, I suppose.

On Thu, Mar 30, 2017 at 2:56 PM, Nathan Bouscal <[hidden email]> wrote:
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?
 
No, there isn't a consensus in either direction. As I understand it, the basic argument for pairs being functors is that there is a single possible way of making them functors, and that that instance is useful sometimes, so someone is going to define it anyway. One of the more convincing (to me) ways it (and other similar instances) is useful is as a building block for other types; Free and Cofree were mentioned last time this was discussed. The argument isn't so much about any specific instance being valuable, but rather about the health of the ecosystem of algebraic structures. Having arbitrary gaps in instance coverage because some people don't like those specific instances really doesn't seem reasonable.

I also don't agree with your description of it as an "anonymous Reader". The Functor instance is the only possible Functor instance for the type; "Reader" is an additional semantic description of one way of thinking about that instance.


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Vladislav Zavialov
In reply to this post by Theodore Lief Gannon
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 <[hidden email]> 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 <[hidden email]> 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
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Tony Morris-4
In reply to this post by Theodore Lief Gannon

But length is not a bad name. The length of ((,) a) is exactly one. It's because people keep calling this "the tuple instance", unaware that it is not the tuple instance. It is a conflation in vocabulary, leading to a misunderstanding of concepts and subsequent practical application.

Jakub Daniel is exactly right, "It is categorically valid to view (a,-) as a functor. It is no different from 0 being an integer"

Is 0 an integer? Is ((,) a) a functor? Is the length of ((,) a) equal to one?

Whichever universe you choose to live in, these questions all have the same answer. I would respect the contrary position more if it was also argued that 0 is not an integer.


On 31/03/17 07:53, Theodore Lief Gannon 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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries




_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

signature.asc (499 bytes) Download Attachment
1234
Loading...