Skip to content

Commit

Permalink
change name and haddock, updated logic to prioritize error from This …
Browse files Browse the repository at this point in the history
…vs That
  • Loading branch information
Isaac Shapira committed Jul 17, 2018
1 parent c2c778c commit bf06fa4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Data/These.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Data.These (
, fromThese
, mergeThese
, mergeTheseWith
, fromAlt
, optionally

-- * Traversals
, here, there
Expand Down Expand Up @@ -110,9 +110,10 @@ mergeThese = these id id
mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c
mergeTheseWith f g op t = mergeThese op $ mapThese f g t

-- | Construct These inside an Alternative.
fromAlt :: Alternative f => f a -> f b -> f (These a b)
fromAlt x y = These <$> x <*> y <|> That <$> y <|> This <$> x
-- | Construct These inside an Alternative.
-- Consider @Control.Applicative.optional` for intuition.
optionally :: Alternative f => f a -> f b -> f (These a b)
optionally x y = These <$> x <*> y <|> This <$> x <|> That <$> y

-- | 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 bf06fa4

Please sign in to comment.