HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulethese-skinny-0.7.6Haskell2010

Data.These

The These type and associated operations.

Contents
  1. Functions to get rid of These
  2. Traversals
  3. Case selections
  4. Case predicates
  5. Map operations
Synopsis
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

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.

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

BiMap and coalesce results with the provided operation.

Traversals

Case selections

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

Select each constructor and partition them into separate lists.

Case predicates

Map operations

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