mirror of
https://github.com/github/semantic.git
synced 2024-12-30 18:36:27 +03:00
Add an applyToBoth
function.
This commit is contained in:
parent
55d952c4c1
commit
41d532dd2d
@ -211,6 +211,10 @@ applyThese :: Join These (a -> b) -> Join These a -> Maybe (Join These b)
|
||||
applyThese (Join fg) (Join ab) = fmap Join . uncurry maybeThese $ uncurry (***) (bimap (<*>) (<*>) (unpack fg)) (unpack ab)
|
||||
where unpack = fromThese Nothing Nothing . bimap Just Just
|
||||
|
||||
-- | Like `<*>`, but it takes a `Both` on the right to ensure that it can always return a value.
|
||||
applyToBoth :: Join These (a -> b) -> Both a -> Join These b
|
||||
applyToBoth (Join fg) (Join (a, b)) = Join $ these (This . ($ a)) (That . ($ b)) (\ f g -> These (f a) (g b)) fg
|
||||
|
||||
-- Map over the bifunctor inside a Join, producing another Join.
|
||||
modifyJoin :: (p a a -> q b b) -> Join p a -> Join q b
|
||||
modifyJoin f = Join . f . runJoin
|
||||
|
Loading…
Reference in New Issue
Block a user