-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
status: needs more infoThis issue needs more info before any action can be done.This issue needs more info before any action can be done.
Description
So I came up with this thing:
what
:: forall f g t a b
. Functor f
=> Functor g
=> Newtype t b
=> (b -> t)
-> ((g b -> g t) -> a -> f t)
-> a
-> f b
what _ f = map unwrap <<< f (map wrap)I was thinking about calling it traverseF, but that's not really right at all aside from superficially having the same shape for the value being operated on and result.
The use case is motivated by @matthewleon's semigroups, for example, the First semigroup can replace the current First monoid provided by Maybe, but it works in a different way, you'd use it something like this:
map (un First) $ foldMap1 (map First) =<< NEA.fromArray [Nothing, Just "foo", Just "bar", Nothing]Or with the combinator:
what First foldMap1 =<< NEA.fromArray [Nothing, Just "foo", Just "bar", Nothing]So it's an ala kind of thing, but kinda traverse-y too 😄 It's part way between ala (map unwrap (f wrap) and alaF (map unwrap <<< f <<< map wrap). alaT? 😉
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: needs more infoThis issue needs more info before any action can be done.This issue needs more info before any action can be done.