by xena · 6mo ago · 0 comments
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 interfaceNo 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].
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.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
Thank you for clarifying this for me.
That is what I meant. Struggling to picture what the other "nonsensical" thing is.
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.