HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulethese-skinny-0.7.6Haskell2010

Data.These

The These type and associated operations.

  • 1 type
  • 19 values
datadata These a b
#

The These type represents values with two non-exclusive possibilities.

This can be useful to represent combinations of two values, where the combination is defined if either input is. Algebraically, the type These A B represents (A + B + AB), which doesn't factor easily into sums and products--a type like Either A (B, Maybe A) is unclear and awkward to use.

These has straightforward instances of Functor, Monad, &c., and behaves like a hybrid error/writer monad, as would be expected.

Constructors

Instances17Bifoldable, Bifunctor, Bitraversable, Monad, Functor, Applicative, …

Functions to get rid of These

4 declarations
valuethese :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
#

Case analysis for the These type.

valuefromThese :: a -> b -> These a b -> (a, b)
#

Takes two default values and produces a tuple.

valuemergeThese :: (a -> a -> a) -> These a a -> a
#

Coalesce with the provided operation.

valuemergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c
#

BiMap and coalesce results with the provided operation.

Traversals

2 declarations

Case selections

7 declarations
valuepartitionThese :: [These a b] -> ([(a, b)], ([a], [b]))
#

Select each constructor and partition them into separate lists.

Case predicates

3 declarations

Map operations

3 declarations

For zipping and unzipping of structures with These values, see Data.Align.