Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data These a b
- these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
- fromThese :: a -> b -> These a b -> (a, b)
- mergeThese :: (a -> a -> a) -> These a a -> a
- mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c
- partitionThese :: [These a b] -> ([a], [b], [(a, b)])
- partitionHereThere :: [These a b] -> ([a], [b])
- partitionEithersNE :: NonEmpty (Either a b) -> These (NonEmpty a) (NonEmpty b)
- distrThesePair :: These (a, b) c -> (These a c, These b c)
- undistrThesePair :: (These a c, These b c) -> These (a, b) c
- distrPairThese :: (These a b, c) -> These (a, c) (b, c)
- undistrPairThese :: These (a, c) (b, c) -> (These a b, c)
Documentation
The strict these type.
Instances
Functions to get rid of These
these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c Source #
Case analysis for the These
type.
mergeThese :: (a -> a -> a) -> These a a -> a Source #
Coalesce with the provided operation.
mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c Source #
bimap
and coalesce results with the provided operation.
Partition
partitionThese :: [These a b] -> ([a], [b], [(a, b)]) Source #
Select each constructor and partition them into separate lists.
partitionHereThere :: [These a b] -> ([a], [b]) Source #
Select here
and there
elements and partition them into separate lists.
partitionEithersNE :: NonEmpty (Either a b) -> These (NonEmpty a) (NonEmpty b) Source #
Like partitionEithers
but for NonEmpty
types.
Note: this is not online algorithm. In the worst case it will traverse the whole list before deciding the result constructor.
>>>
partitionEithersNE $ Left 'x' :| [Right 'y']
These ('x' :| "") ('y' :| "")
>>>
partitionEithersNE $ Left 'x' :| map Left "yz"
This ('x' :| "yz")
Distributivity
This distributivity combinators aren't isomorphisms!
distrPairThese :: (These a b, c) -> These (a, c) (b, c) Source #
undistrPairThese :: These (a, c) (b, c) -> (These a b, c) Source #