3 ms·
It's possible to define an map function for a container today https://go.dev/play/p/zcP6FZcBzyC https://go.dev/play/p/zcP6FZcBzyC You can also define an fmap
by rowanG077 2y ago
It's possible to define an map function for a container
today https://go.dev/play/p/zcP6FZcBzyC https://go.dev/play/p/zcP6FZcBzyC
You can also define an fmap interface that doesn't actually map the type, but can apply function that do not change the type: https://go.dev/play/p/836wr3nuw4U https://go.dev/play/p/836wr3nuw4U
But currently I don't think it's possible to combine this. That is have an fmap as it is in Haskell. You would need to capability to add generic arguments to an interface. It could look something like this:
https://go.dev/play/p/E_emmGUOoIz https://go.dev/play/p/E_emmGUOoIz
- grandempire 2y agoThis is very helpful. Thanks.