4 ms·
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: t
by assbuttbuttass 4mo ago
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
- _jackdk_ 4mo 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 4mo 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_ 4mo agoYeah you would, that's true.