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

69 messages
1234
Open this post in threaded view
|

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

 Henning Thielemann <[hidden email]> writes: > 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). I wholeheartedly agree. -1 from me on all such proposals. I’m greatly dismayed at the rate at which arguments for convenience are winning over arguments for correctness. -- Jón Fairbairn                                 [hidden email] _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 In reply to this post by Henning Thielemann 2017-03-30 23:49 GMT+02:00 Henning Thielemann :The community was and is pretty divided, I think. My suggested compromise is to get compiler warnings if you use certain instances (by accident).I fully agree with Henning here, and I think we will never ever reach a consensus about these instances. This is caused by the fact that there are 2 contradicting goals here, and which one is more important is a totally personal opinion, not something which can be proved or shown otherwise:   * Type safety, a.k.a. "if it compiles, it works": We definitely lose on this side with the given instances, and we lose even more when there are more instances.   * Consistency: If there is a unique way to define an instance, let's do it, and do it for *all* such types. Just like type safety, this is a valuable goal, and one which is reached by Haskell to very large amount.Personally, I would very much prefer nuking the Functor/... instances for pairs, the resulting length/maximum/... semantics are total nonsense, even if they are consistent. Let's not forget the "principle of least surprise", a very worthy goal, which is heavily damaged by these instances. But the pair instances are already there, and removing them would damage the Haskell ecosystem quite a bit. So what can we do?   a) Actually nuke the pair instances, accepting the resulting damage and "holes".   b) Keep the pair instances. But then we should really add the remaining tuple instances, too (consistency!), *and* we should add a compiler flag/pragma for people wanting to avoid them.So a reluctant +1 for b), but only *after* we have a flag/pragma. A strong -1 for adding the instances before such a flag/pragma.Next battle: What will be the default for the flag/pragma? >:-) _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 On Fri, 31 Mar 2017, Sven Panne wrote: > So a reluctant +1 for b), but only *after* we have a flag/pragma. A > strong -1 for adding the instances before such a flag/pragma. Generally we should first have a way to limit damage before adding more type unsafety. Currently re-adding safety belts lags years behind reduction of type safety. Btw. the ticket is https://ghc.haskell.org/trac/ghc/ticket/11796> Next battle: What will be the default for the flag/pragma? >:-) I'd prefer that this warning is enabled by default. Next best solution is to integrate the warning in Wall. There are people who even find that too annoying. Using the new selective conversion of warnings to errors we can also get back type errors:     https://ghc.haskell.org/trac/ghc/ticket/11219_______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 In reply to this post by Bryan Richter-2 On Thu, Mar 30, 2017 at 10:47 PM Bryan Richter <[hidden email]> wrote:I just don't know why pairs ever got to Functor. I fear this was an ancient decision... no?If you're curious, this happened over 10 years ago: _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 On Fri, 31 Mar 2017, Herbert Valerio Riedel wrote: > On Thu, Mar 30, 2017 at 10:47 PM Bryan Richter <[hidden email]> wrote: >       I just don't know why pairs ever got to Functor. I fear this was an ancient decision... no? > > > If you're curious, this happened over 10 years ago: > > http://git.haskell.org/ghc.git/commitdiff/209bf03ac7949c9bcf677561a2b1360b158e3b22Interesting. The Functor instance for pairs was added together with the Functor instance for functions. But the Monad instance for pairs came later, right? _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 In reply to this post by Sven Panne-2 A contrary, consistent position would mean there is a belief in all of the following: * the length of any value of the type ((,) a) is not 1 * 0 is not an integer I have never seen this position, which would be a consistent, third position. These leaves two remaining positions; one of consistency and one of inconsistency. Restated: * the length semantics of ((,) a) are total nonsense. * that 0 is an integer, is total nonsense. I could totally respect this position. It would make a lot more sense. It would be consistent. It would be defendable. I would admire it. On 31/03/17 19:23, Sven Panne wrote: 2017-03-30 23:49 GMT+02:00 Henning Thielemann : The community was and is pretty divided, I think. My suggested compromise is to get compiler warnings if you use certain instances (by accident). I fully agree with Henning here, and I think we will never ever reach a consensus about these instances. This is caused by the fact that there are 2 contradicting goals here, and which one is more important is a totally personal opinion, not something which can be proved or shown otherwise:    * Type safety, a.k.a. "if it compiles, it works": We definitely lose on this side with the given instances, and we lose even more when there are more instances.    * Consistency: If there is a unique way to define an instance, let's do it, and do it for *all* such types. Just like type safety, this is a valuable goal, and one which is reached by Haskell to very large amount. Personally, I would very much prefer nuking the Functor/... instances for pairs, the resulting length/maximum/... semantics are total nonsense, even if they are consistent. Let's not forget the "principle of least surprise", a very worthy goal, which is heavily damaged by these instances. But the pair instances are already there, and removing them would damage the Haskell ecosystem quite a bit. So what can we do?    a) Actually nuke the pair instances, accepting the resulting damage and "holes".    b) Keep the pair instances. But then we should really add the remaining tuple instances, too (consistency!), *and* we should add a compiler flag/pragma for people wanting to avoid them. So a reluctant +1 for b), but only *after* we have a flag/pragma. A strong -1 for adding the instances before such a flag/pragma. Next battle: What will be the default for the flag/pragma? >:-) _______________________________________________ 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
Open this post in threaded view
|

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

 In reply to this post by Henning Thielemann The Monad instance for pairs came later mostly because there was a big dependency inversion / orphan problem with getting at Monoid for it, but yes.-EdwardOn Fri, Mar 31, 2017 at 1:24 PM, Henning Thielemann wrote: On Fri, 31 Mar 2017, Herbert Valerio Riedel wrote: On Thu, Mar 30, 2017 at 10:47 PM Bryan Richter <[hidden email]> wrote:       I just don't know why pairs ever got to Functor. I fear this was an ancient decision... no? If you're curious, this happened over 10 years ago: http://git.haskell.org/ghc.git/commitdiff/209bf03ac7949c9bcf677561a2b1360b158e3b22 Interesting. The Functor instance for pairs was added together with the Functor instance for functions. But the Monad instance for pairs came later, right? _______________________________________________ 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
Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

 On 01/04/17 17:24, Andreas Abel wrote: > > The length of ((,) a) is exactly one. Anything else is ridiculous. > > Now we are even talking of the length of a function.  Can it get more > absurd?! No. It is perfectly reasonable. Go and "ask the mathematics department" or whatever criteria it will take for (the collective) you to understand that. > Just make a field experiment.  Go to the mathematics department and > ask people what is the length of (1, 1), the length of (1, 1, 1).  An > then count the number of people that respond "1" to both of these > questions. And weight it against the people that say something else. We already agree on the result. Thanks again for pointing out, that I am pointing to the mistake that is repeatedly made. I will just keep pointing to it. Just keep that mistake out of my code, thanks. _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries signature.asc (499 bytes) Download Attachment
Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

 In reply to this post by Fumiaki Kinoshita Since "God made the integers…” perhaps the question of whether 0 is an integer is best left to theologians. On the other hand, in set theory a tuple is defined as a set containing two elements and in category theory, a product is a limit of a discrete category with two objects. Of course you can treat a tuple as a decorated container containing one element but I doubt many mathematicians think of them this way. Before anyone points out that I shouldn’t think of types as sets, the same applies to \omega-complete partial orders. Perhaps I had better be explicit and say please no aka -1. > The length of ((,) a) is exactly one. Anything else is ridiculous. Try > arguing against that, instead of a position that does not exist ("length > of tuples"). I wrote this instance some number of years ago (about 11), > and have used it on teams all over the place. Not once was there an > issue that was not quickly corrected, and thereby achieving the > practical benefits that come with, by providing a better understanding. > That understanding is above. The length of ((,) a) is exactly one. Say > it with me. > > > On 01/04/17 10:08, Francesco Ariis wrote: >> On Sat, Apr 01, 2017 at 07:59:00AM +1000, Tony Morris wrote: >>> A contrary, consistent position would mean there is a belief in all of >>> the following: >>> >>> * the length of any value of the type ((,) a) is not 1 >>> * 0 is not an integer Dominic Steinitz [hidden email] http://idontgetoutmuch.wordpress.com_______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

 On Sat, 1 Apr 2017, Jakub Daniel wrote: > And I imagine nobody would argue that doesn't make sense. I kind of see > why people want better name than length but I see no really good > argument why the instance is bad. There are no doubt other generalised > notions. It also was an unfair question to ask what mathematicians would > think the length of (1,1) was. Because the question is not asked in > context where we ask about length for the type (a,-) not (-,-). And for me the context (a,-) is artificial. _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

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

 In reply to this post by Andreas Abel-2 On Sat, 1 Apr 2017, Andreas Abel wrote: > In the end, I should be grateful for the FTP.  It will provide amusement > for years. > > Q: What is the length of pi? > A: Dunno, infinity? > Q: And what is the length of just pi? > > GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help > Prelude> length (Just pi) > 1 > > ROFL. I have to admit that I even accept this more than length on pairs. I used to use Maybe for lists with length 0 or 1. _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries