3 ms·
This reminds me of Haskell's 'functor' [1] [1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-Functor.html https://hackage.haskell.org/package/bas
by ToJans 3y ago
This reminds me of Haskell's 'functor' [1]
[1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-Functor.html https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-...
- masklinn 3y agoVery much so, it’s a functor instance on some sort of tree, except the `map` includes a conditional dispatch. It’s essentially fmap $ ap fromMaybe Except this doesn’t quite work, I’m sure there’s a pointfree version, best I can achieve is \p -> fmap $ ap fromMaybe p Which takes an `a -> Maybe a` and an `[a]`, and replaces all the values for which the callback returns `Some`, and leaves as-is all the values for which it returns `None`. (I collapsed the `whereFn` and `updateFn` into a single one because there’s no reason not to)
- gdprrrr 3y agoYou're looking for `fmap . ap fromMaybe`