5 ms·
This will finally let me make the monad library I've been dreaming of for years. Be afraid.
by xena 5mo ago
This will finally let me make the monad library I've been dreaming of for years. Be afraid.
- nasretdinov 5mo agoWe already have monads at home (return X, err)
- bonesss 5mo agoA monad library in go can really on have one name… …
- oh_fiddlesticks 5mo agoGo nad or go home
- digitaltrees 5mo agoUnderrated
- zephen 5mo agoMo-go?
- throwaway894345 5mo agoMongo
- WesolyKubeczek 5mo ago(is appalled!)
- whaleofatw2022 5mo agoStrife
- uproarchat 5mo agoWeeee
- hennilu 5mo agoGoMad
- dnnddidiej 5mo agoCan we have Exception monads? Asking for friend.
- AdieuToLogic 5mo ago> 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 https://wiki.haskell.org/Monad_laws 1 - https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Either.html 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 https://www.scala-lang.org/api/3.8.3/scala/util/Either.html
- lacker 5mo agoI 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 https://wiki.haskell.org/index.php?title=All_About_Monads
- AdieuToLogic 5mo agoI 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.
- dnnddidiej 5mo ago> 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.
- 5mo ago
- assbuttbuttass 5mo agoIt'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
- _jackdk_ 5mo agoI 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]?
- assbuttbuttass 5mo agoHmm 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
- _jackdk_ 5mo agoYeah you would, that's true.
- 9rx 5mo agoFunnily enough, Go's generics were designed by the same guy who introduced monads to computer science. Everything comes fill circle.
- AdieuToLogic 5mo ago> 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 https://en.wikipedia.org/wiki/Category_theory
- rustyzig 5mo agoAs 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/baastad.pdf 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 https://homepages.inf.ed.ac.uk/wadler/topics/go.html
- throwway262515 5mo agoOn that note, calculus come from physics. AI should really hand back all those jacobians and hessians.
- AdieuToLogic 5mo ago> 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.