Add missing Monad/Traversable instances to tuples

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Add missing Monad/Traversable instances to tuples

Andreas Abel
Indeed.

Abusing tuples for the writer monad was a bad idea in the first place.
There is no need to drive a bad idea further to the bitter end.

Another way to put it:

Not everything that is mathematically consequential is good software
engineering practice.

On 2019-04-04 07:54, Henning Thielemann wrote:

>
> On Thu, 4 Apr 2019, Bryan Richter wrote:
>
>> I also understand the consistency aesthetic, and I would support
>> efforts to make it feasible. The onus to "write a patch", though, is
>> on the side of people championing this aesthetic. :)
>
> In Germany there is a law: If you damage environment in the course of a
> construction, you must compensate this somehow. E.g. if you fell a tree
> you must plant some new ones. Analogously, if you reduce type safety in
> a way then add compensation in another way. That is, I also think that
> it is the obligation of the instance proposers to also implement some
> instance warning. I would not be surprised if they find out this way
> that we have a case of YAGNI.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Add missing Monad/Traversable instances to tuples

Ganesh Sittampalam
In reply to this post by Carter Schonwald
On 03/04/2019 02:27, Carter Schonwald wrote:

> so from my perspective, while yes, some folks use tuples for fixed size
> homogenuous collections, they are useful powerful tools in the algebra
> of types and functional programming jiggery pokery! There is no sound
> reason to cripple our official prepresentative of the the simple
> polymorphic product type formal, the "*" of our haskell and the eternal
> dual of the sum of our cases! ;)
>
> strong +1, let the algebras roar :) 
>
> to be clear, the arguments against are valid, but i thnk they could be
> addressed by identifying the changes / tooling that would enable a
> better fitting of intent. buggy code happens, fix the root, not the symptom

For the record I think the root cause here *is* the instances, and
anything we do later is just sticking plaster. In my mind the instances
are the moral equivalent of using dynamic types.

Cheers,

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

Re: Add missing Monad/Traversable instances to tuples

Henrik Nilsson-2
In reply to this post by Andreas Abel
Hi,

Andreas Abel wrote:

 > Abusing tuples for the writer monad was a bad idea in the first place.
 > There is no need to drive a bad idea further to the bitter end.
 >
 > Another way to put it:
 >
 > Not everything that is mathematically consequential is good software
 > engineering practice.

I could not agree more. Except that I hold that the mathematical
consequence in this case only makes sense if a very particular
perspective is adopted. From other, equally valid, perspectives,

     sum (2,3) = 3

etc. is simply nonsensical.

-1 from me too.

And for the record:


Ganesh Sittampalam replied replied to Carter Schoenwald:
 > > to be clear, the arguments against are valid, but i thnk they could
 > > be
 > > addressed by identifying the changes / tooling that would enable a
 > > better fitting of intent. buggy code happens, fix the root, not the
 > > symptom
 >
 > For the record I think the root cause here *is* the instances, and
 > anything we do later is just sticking plaster. In my mind the
 > instances are the moral equivalent of using dynamic types.

I fully agree with this too, and if the only purpose of the
proposed tooling indeed is to be a "plaster" for users who
accidentally get hurt by sharp edges that really should not be
there in the first place, then that seems to be not only
wholly unnecessary, but a downright dangerous direction.

Best,

/Henrik



This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment.

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored
where permitted by law.




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

Re: Add missing Monad/Traversable instances to tuples

Richard Eisenberg-5
In reply to this post by Andreas Abel


On Apr 4, 2019, at 3:12 AM, Andreas Abel <[hidden email]> wrote:

Not everything that is mathematically consequential is good software engineering practice.

+1 to that -- which means -1 to the proposal.

I might change my mind if the proposal includes the instance warnings, following Henning's reasoning.

Richard

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

Re: Add missing Monad/Traversable instances to tuples

Elliot Cameron-2
I agree with Andreas and Henning's line of reasoning: Add the instances IFF we have warnings for them and can effectively outlaw them in our codebases if we want to. If we take this stance both sides of the debate are motivated to add the feature.

On Thu, Apr 4, 2019 at 9:45 AM Richard Eisenberg <[hidden email]> wrote:


On Apr 4, 2019, at 3:12 AM, Andreas Abel <[hidden email]> wrote:

Not everything that is mathematically consequential is good software engineering practice.

+1 to that -- which means -1 to the proposal.

I might change my mind if the proposal includes the instance warnings, following Henning's reasoning.

Richard
_______________________________________________
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
|

[UPDATED] Add missing Monad instances to tuples

Fumiaki Kinoshita
In reply to this post by Fumiaki Kinoshita
I removed Foldable/Traversable instances from the patch with reluctance. I'd still like to add these instances:

Functor ((,,) a b)
(Monoid a, Monoid b) => Applicative ((,,) a b)
(Monoid a, Monoid b) => Monad ((,,) a b)
Functor ((,,,) a b c)
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

2019年4月2日(火) 13:28 Fumiaki Kinoshita <[hidden email]>:
I submitted https://gitlab.haskell.org/ghc/ghc/merge_requests/644 but it might be still controversial. I'd like to get more opinions again.

Here's the list of proposed instances:

Foldable ((,,) a b)
Foldable ((,,,) a b c)
Traversable ((,,) a b)
Traversable ((,,,) a b c)
Functor ((,,) a b)
(Monoid a, Monoid b) => Applicative ((,,) a b)
(Monoid a, Monoid b) => Monad ((,,) a b)
Functor ((,,,) a b c)
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

The absence of Traversable instances for tuples feels quite inconsistent given that there are Bitraversable instances already.

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

Re: [UPDATED] Add missing Monad instances to tuples

Henning Thielemann

On Sun, 7 Apr 2019, Fumiaki Kinoshita wrote:

> I removed Foldable/Traversable instances from the patch with reluctance. I'd still like to add these instances:
>
> Functor ((,,) a b)
> (Monoid a, Monoid b) => Applicative ((,,) a b)
> (Monoid a, Monoid b) => Monad ((,,) a b)
> Functor ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

Still duplicates to the Writer monad.

How about extending the patch by the long needed instance warnings? :-)
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: [UPDATED] Add missing Monad instances to tuples

Fumiaki Kinoshita
They are writer monads for sure, but WriterT does not subsume them. If a typeclass method has type Writer w a, it does not allow GeneralizedNewtypeDeriving on it due to the type roles.

I don't really have any idea how instance warnings should look like.

2019年4月7日(日) 17:58 Henning Thielemann <[hidden email]>:

On Sun, 7 Apr 2019, Fumiaki Kinoshita wrote:

> I removed Foldable/Traversable instances from the patch with reluctance. I'd still like to add these instances:
>
> Functor ((,,) a b)
> (Monoid a, Monoid b) => Applicative ((,,) a b)
> (Monoid a, Monoid b) => Monad ((,,) a b)
> Functor ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

Still duplicates to the Writer monad.

How about extending the patch by the long needed instance warnings? :-)

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

Re: [UPDATED] Add missing Monad instances to tuples

Henning Thielemann

On Sun, 7 Apr 2019, Fumiaki Kinoshita wrote:

> They are writer monads for sure, but WriterT does not subsume them. If a typeclass method has type Writer w a, it
> does not allow GeneralizedNewtypeDeriving on it due to the type roles.
>
> I don't really have any idea how instance warnings should look like.

https://gitlab.haskell.org/ghc/ghc/issues/11796
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: [UPDATED] Add missing Monad instances to tuples

Mario Blažević
In reply to this post by Fumiaki Kinoshita
On 2019-04-07 4:54 a.m., Fumiaki Kinoshita wrote:
> I removed Foldable/Traversable instances from the patch with reluctance.
> I'd still like to add these instances:
>
> Functor ((,,) a b)
> (Monoid a, Monoid b) => Applicative ((,,) a b)
> (Monoid a, Monoid b) => Monad ((,,) a b)
> Functor ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

You have a +1 from me. I can't wait to hear the objections to these.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
12