News for hackers. Stuff that matters.
Re:Go: Support for Generic Methods by xena on Wednesday May 27, 2026 @01:26PM (#48297504)
This will finally let me make the monad library I've been dreaming of for years. Be afraid.
Re:Go: Support for Generic Methods by bonesss on Wednesday May 27, 2026 @02:41PM (#48298586)
A monad library in go can really on have one name… …
Re:Go: Support for Generic Methods by oh_fiddlesticks on Wednesday May 27, 2026 @03:29PM (#48299285)
Go nad or go home
Re:Go: Support for Generic Methods by digitaltrees on Wednesday May 27, 2026 @11:11PM (#48303987)
Underrated
Re:Go: Support for Generic Methods by zephen on Wednesday May 27, 2026 @06:48PM (#48301815)
Mo-go?
Re:Go: Support for Generic Methods by throwaway894345 on Wednesday May 27, 2026 @06:53PM (#48301866)
Mongo
Re:Go: Support for Generic Methods by WesolyKubeczek on Thursday May 28, 2026 @08:14AM (#48307840)
(is appalled!)
Re:Go: Support for Generic Methods by whaleofatw2022 on Wednesday May 27, 2026 @11:21PM (#48304068)
Strife
Re:Go: Support for Generic Methods by uproarchat on Thursday May 28, 2026 @03:00AM (#48305588)
Weeee
Re:Go: Support for Generic Methods by hennilu on Thursday May 28, 2026 @03:11AM (#48305661)
GoMad
Re:Go: Support for Generic Methods by nasretdinov on Wednesday May 27, 2026 @02:03PM (#48298052)
We already have monads at home (return X, err)
Re:Go: Support for Generic Methods by dnnddidiej on Wednesday May 27, 2026 @07:09PM (#48302011)
Can we have Exception monads? Asking for friend.
Re:Go: Support for Generic Methods by AdieuToLogic on Thursday May 28, 2026 @01:02AM (#48304749)
> Can we have Exception monads? Asking for friend.

This is nonsensical. Monads define a strict set of behaviors formalized as "monad laws"[0].

Perhaps what you want is a container which adheres to monad laws capable of abstracting exceptions. Two exemplars of same are Haskell's Data.Either[1] and Scala's Either[2].

0 - https://wiki.haskell.org/Monad_laws

1 - https://hackage-content.haskell.org/package/base-4.22.0.0/do...

2 - https://www.scala-lang.org/api/3.8.3/scala/util/Either.html

Re:Go: Support for Generic Methods by lacker on Thursday May 28, 2026 @01:17AM (#48304859)
I don't think it's nonsensical, it's just another name for the same thing. E.g. in the Haskell wiki it says, "the Error monad, also called the Exception monad".

https://wiki.haskell.org/index.php?title=All_About_Monads

Re:Go: Support for Generic Methods by AdieuToLogic on Thursday May 28, 2026 @10:58PM (#48318468)
I was unaware of "Exception monad" being an industry equivalent term for Either/Error. Given no other context, desiring an "Exception monad" could be interpreted as "a type which handles raising Exception types." Which is how I did.

Thank you for clarifying this for me.

Re:Go: Support for Generic Methods by dnnddidiej on Thursday May 28, 2026 @06:10AM (#48306893)
> Perhaps what you want is a container which adheres to monad laws capable of abstracting exceptions

That is what I meant. Struggling to picture what the other "nonsensical" thing is.

Re:Go: Support for Generic Methods by AdieuToLogic on Thursday May 28, 2026 @11:02PM (#48318491)
As I commented here[0], my interpretation of:

  Can we have Exception monads? Asking for friend.
Was a desire to have "a type which handles raising Exception types." Until now, I was unaware of "Exception monad" being an alternate moniker for Either/Error types.

0 - https://news.ycombinator.com/item?id=48318468

Re:Go: Support for Generic Methods by assbuttbuttass on Wednesday May 27, 2026 @08:21PM (#48302609)
It's (sadly) still not possible to express monads with this change, since generic methods can't implement interfaces. You'd probably want something like:

    type Monad[T any] interface {
        Bind[U any](func(T) Monad[U])
    }
However this requires the Bind method to be generic, which still isn't allowed in an interface
Re:Go: Support for Generic Methods by _jackdk_ on Wednesday May 27, 2026 @10:35PM (#48303706)
I am not very familiar with Go and especially not its generics support. Can you implement the "join" version instead of the "bind" version, where you turn a T[T[a]] into a T[a]?
Re:Go: Support for Generic Methods by assbuttbuttass on Thursday May 28, 2026 @08:52AM (#48308247)
Hmm I wasn't familiar with join, but it looks like you still need join + fmap for the construction? I believe fmap would also need a generic method
Re:Go: Support for Generic Methods by _jackdk_ on Thursday May 28, 2026 @06:19PM (#48316327)
Yeah you would, that's true.
Re:Go: Support for Generic Methods by 9rx on Thursday May 28, 2026 @12:00AM (#48304328)
Funnily enough, Go's generics were designed by the same guy who introduced monads to computer science. Everything comes fill circle.
Re:Go: Support for Generic Methods by AdieuToLogic on Thursday May 28, 2026 @12:56AM (#48304692)
> Funnily enough, Go's generics were designed by the same guy who introduced monads to computer science.

No contributor to Go is responsible for "introducing monads to computer science", as the Monad concept is a member of (or defined by if you prefer) Category Theory[0].

0 - https://en.wikipedia.org/wiki/Category_theory

Re:Go: Support for Generic Methods by rustyzig on Thursday May 28, 2026 @01:05AM (#48304773)
As you point out, monads come from category theory, not native to computer science. Thus there had to be someone to introduce approaches to applying monads in computer science. The paper usually credited with that is: https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/b... Which the parent rightfully points out was written by the same person primarily responsible for the design of generics in Go: https://homepages.inf.ed.ac.uk/wadler/topics/go.html
Re:Go: Support for Generic Methods by throwway262515 on Thursday May 28, 2026 @05:03AM (#48306465)
On that note, calculus come from physics. AI should really hand back all those jacobians and hessians.
Re:Go: Support for Generic Methods by AdieuToLogic on Thursday May 28, 2026 @11:18PM (#48318591)
> As you point out, monads come from category theory, not native to computer science. Thus there had to be someone to introduce approaches to applying monads in computer science.

With full respect given to Wadler and his contributions to computer science, the very paper you cite authored by Wadler declares:

  The concept of a monad, which arises from category theory, 
  has been applied by Moggi to structure the denotational 
  semantics of programming languages.
Therefore, one cannot assert that a computer scientist whom identifies a predecessor's contributions such as above is, in fact, responsible for said contributions.
Re:Go: Support for Generic Methods by rustyzig on Friday May 29, 2026 @01:57PM (#48326844)
And with full respect also given to Moggi, introductions are only introductions if they are heard.

If we were talking about the first person to discover monads, Wadler clearly would not be he. Wadler was but a wee toddler barely sputtering out his first words when the term "monad" was coined. As we are talking about who introduced monads to computer science, the signs I see continue to point to Wadler. His work is, by all appearances, what caught the attention of the computer science community. "Monads for functional programming" is regularly cited as the seminal paper. They are strongly associated with Haskell. It would even appear from the previous comment that you only came to learn about Moggi because of Wadler making his introduction, which echos Moggi not being particularly influential socially.

If you have evidence to suggest that Moggi played a bigger role in introducing (not inventing) the concepts, I am definitely keen to learn about it.

Re:Go: Support for Generic Methods by AdieuToLogic on Friday May 29, 2026 @08:08PM (#48330965)
> If we were talking about the first person to discover monads, Wadler clearly would not be he.

We are not. Remember what the OP stated, to which I originally replied:

  Funnily enough, Go's generics were designed by the same guy 
  who introduced monads to computer science.
This is demonstrably incorrect, as Wadler did not "introduce monads to computer science" and is what I disagreed with alone.

Did Wadler take monads to new and important levels in both computer science and software engineering? Absolutely!

> It would even appear from the previous comment that you only came to learn about Moggi because of Wadler making his introduction, which echos Moggi not being particularly influential socially.

I quoted the Moggi attribution due to it being present in the paper you kindly provided. Whether Moggi has any influence socially is irrelevant as it pertains to the original thesis discussed above.

> If you have evidence to suggest that Moggi played a bigger role in introducing (not inventing) the concepts, I am definitely keen to learn about it.

Again, this is not germane to the aforementioned OP statement.

Re:Go: Support for Generic Methods by rustyzig on Saturday May 30, 2026 @12:36AM (#48332620)
Moggi's social influence is everything as introductions can only happen in the social realm. It continues that all evidence I can find suggests that his work went unnoticed until Wadler pushed it into view. In other words, people came to learn about his work only because of Wadler making the introduction. Nobody, except where one may find it trying to be implied in https://news.ycombinator.com/item?id=48304692, has suggested Wadler invented monads. The OP clearly wrote "introduced", not "invented".