Skip to content

Commit

Permalink
Add mergeWithThese.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxigit committed Mar 1, 2015
1 parent 7fe759f commit 3c3dc27
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Data/These.hs
Expand Up @@ -9,6 +9,7 @@ module Data.These (
, these
, fromThese
, mergeThese
, mergeTheseWith

-- * Traversals
, here, there
Expand Down Expand Up @@ -85,6 +86,10 @@ fromThese _ _ (These a x) = (a, x)
mergeThese :: (a -> a -> a) -> These a a -> a
mergeThese = these id id

-- | BiMap and coalesce results with the provided operation.
mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c
mergeTheseWith f g op t = mergeThese op $ mapThese f g t


-- | A @Traversal@ of the first half of a 'These', suitable for use with @Control.Lens@.
here :: (Applicative f) => (a -> f b) -> These a t -> f (These b t)
Expand Down

0 comments on commit 3c3dc27

Please sign in to comment.