Portability | Haskell98 + CPP |
---|---|
Stability | provisional |
Maintainer | wren@community.haskell.org |
A data type for non-exclusive disjunction. This is helpful for
things like a generic merge function on sets/maps which could
be union, mutual difference, etc. based on which Or
value a
function argument returns. Also useful for non-truncating zips
(cf. zipOr
) and other cases where you sometimes want an Either
and sometimes want a pair.
- data Or a b
- elimOr :: (a -> c) -> (a -> b -> c) -> (b -> c) -> Or a b -> c
- eitherOr :: Either a b -> Or a b
- zipOr :: [a] -> [b] -> [Or a b]
- zipOrWith :: (Or a b -> c) -> [a] -> [b] -> [c]
- zipOrBy :: (Or a b -> c -> c) -> c -> [a] -> [b] -> c
- zipOrWithBy :: (Or a b -> c) -> (c -> d -> d) -> d -> [a] -> [b] -> d
Documentation
A data type for non-exclusive disjunction.
Non-truncating zipping functions
zipOr :: [a] -> [b] -> [Or a b]Source
A variant of zip
which exhausts both lists, annotating which
list the elements came from. It will return zero or more Both
,
followed by either zero or more Fst
or else zero or more Snd
.
On GHC this is a "good producer" for list fusion.
zipOrBy :: (Or a b -> c -> c) -> c -> [a] -> [b] -> cSource
A variant of zipOr
with a custom list-homomorphism.