Hacker News new | ask | show | jobs
by masklinn 1016 days ago
Very 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)

1 comments

You're looking for `fmap . ap fromMaybe`