HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleeither-n-0.1.0.0Haskell2010

Data.Either3.Either3

A data type similar to Data.Either with three constructors.

  • 1 type
  • 4 classes
  • 6 values
  • Packageeither-n-0.1.0.0
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceEither3.hs

Data type

1 declaration
datadata Either3 a b c
#

A value of one of three types, similar to Either.

The Functor, Applicative and Monad instances act on the third type parameter, so First3 and Second3 short-circuit, in the same way Left does for Either.

Example1 expression
toConstr (Second3 True :: Either3 String Bool Int)Second3
Example1 expression
to (from (Third3 1 :: Either3 String Bool Int)) :: Either3 String Bool IntThird3 1

Constructors

Instances42Generic1, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, Bifoldable, Bifunctor, …
  • Generic1 (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • FoldableWithIndex () (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • FunctorWithIndex () (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    The index is always (), as for Maybe.

    Example1 expression
    imap (\() x -> x + 1) (Third3 1 :: Either3 String Bool Int)Third3 2
  • TraversableWithIndex () (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • Bifoldable (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    bifoldMap show show (Second3 True :: Either3 String Bool Int)"True"
    Example1 expression
    bifoldMap show show (First3 "x" :: Either3 String Bool Int)""
  • Bifunctor (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    Maps the second and third type parameters.

    Example1 expression
    bimap not (+ 1) (Second3 True :: Either3 String Bool Int)Second3 False
    Example1 expression
    bimap not (+ 1) (Third3 1 :: Either3 String Bool Int)Third3 2
  • Bitraversable (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    bitraverse (\b -> [b, not b]) (\c -> [c]) (Second3 True :: Either3 String Bool Int)[Second3 True,Second3 False]
  • Eq a => Eq2 (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    liftEq2 (==) (==) (Second3 1 :: Either3 String Int Int) (Second3 1)True
    Example1 expression
    liftEq2 (==) (==) (Second3 1 :: Either3 String Int Int) (Third3 1)False
  • Ord a => Ord2 (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    Orders First3 before Second3 before Third3, as the derived Ord does.

    Example1 expression
    liftCompare2 compare compare (First3 "x" :: Either3 String Int Int) (Third3 1)LT
    Example1 expression
    liftCompare2 compare compare (Third3 2 :: Either3 String Int Int) (Third3 1)GT
  • Show a => Show2 (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • Swap (Either3 a)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    Swaps the second and third type parameters.

    Example1 expression
    swap (Second3 True :: Either3 String Bool Int)Third3 True
    Example1 expression
    swap (First3 "x" :: Either3 String Bool Int)First3 "x"
  • Monad (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    Third3 1 >>= (\x -> if x > 0 then Third3 (x + 1) else Second3 False) :: Either3 String Bool IntThird3 2
    Example1 expression
    Second3 True >>= (\x -> Third3 (x + 1)) :: Either3 String Bool IntSecond3 True
  • Functor (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    fmap (+ 1) (Third3 1 :: Either3 String Bool Int)Third3 2
    Example1 expression
    fmap (+ 1) (Second3 True :: Either3 String Bool Int)Second3 True
  • Applicative (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    pure 1 :: Either3 String Bool IntThird3 1
    Example1 expression
    Third3 (+ 1) <*> Second3 True :: Either3 String Bool IntSecond3 True
  • Foldable (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    sum (Third3 1 :: Either3 String Bool Int)1
    Example1 expression
    length (First3 "x" :: Either3 String Bool Int)0
  • Traversable (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    traverse (\x -> [x, x + 1]) (Third3 1 :: Either3 String Bool Int)[Third3 1,Third3 2]
    Example1 expression
    traverse (\x -> [x, x + 1]) (Second3 True :: Either3 String Bool Int)[Second3 True]
  • MonadZip (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    Combines two Third3 values, otherwise the first First3 or Second3, as liftA2 does.

    Example1 expression
    mzip (Third3 1) (Third3 True) :: Either3 String Bool (Int, Bool)Third3 (1,True)
    Example1 expression
    mzip (Second3 False) (First3 "x") :: Either3 String Bool (Int, Bool)Second3 False
  • (Eq a, Eq b) => Eq1 (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    liftEq (==) (Third3 1 :: Either3 String Bool Int) (Third3 1)True
  • (Ord a, Ord b) => Ord1 (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    liftCompare compare (Second3 True :: Either3 String Bool Int) (Third3 1)LT
  • (Show a, Show b) => Show1 (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • Alt (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    The first Third3 wins, otherwise the second value, like Either.

    Example1 expression
    First3 "x" <!> Third3 1 :: Either3 String Bool IntThird3 1
    Example1 expression
    Second3 True <!> First3 "x" :: Either3 String Bool IntFirst3 "x"
  • Apply (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    Third3 (+ 1) <.> Third3 1 :: Either3 String Bool IntThird3 2
    Example1 expression
    First3 "x" <.> Second3 True :: Either3 String Bool IntFirst3 "x"
  • Bind (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    Third3 1 >>- (\x -> Third3 (x + 1)) :: Either3 String Bool IntThird3 2
  • Extend (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    duplicated (Third3 1 :: Either3 String Bool Int)Third3 (Third3 1)
    Example1 expression
    duplicated (Second3 True :: Either3 String Bool Int)Second3 True
  • Selective (Either3 a b)Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    select (Third3 (Left 1)) (Third3 (+ 1)) :: Either3 String Bool IntThird3 2
    Example1 expression
    select (Third3 (Right 1)) (Second3 True) :: Either3 String Bool IntThird3 1
  • (Eq a, Eq b, Eq c) => Eq (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • (Data a, Data b, Data c) => Data (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • (Ord a, Ord b, Ord c) => Ord (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • (Show a, Show b, Show c) => Show (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • Generic (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • Semigroup (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3

    The first Third3 wins, otherwise the second value, like Either.

    Example1 expression
    First3 "x" <> Third3 1 :: Either3 String Bool IntThird3 1
    Example1 expression
    Third3 1 <> Third3 2 :: Either3 String Bool IntThird3 1
    Example1 expression
    First3 "x" <> Second3 True :: Either3 String Bool IntSecond3 True
  • (NFData a, NFData b, NFData c) => NFData (Either3 a b c)Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • AsEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • GetEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • HasEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • ReviewEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • Each (Either3 a a a) (Either3 b b b) a bDefined in either-n-0.1.0.0 · Data.Either3.Either3

    Traverses the single value, like the Each instance for Either a a.

    Example1 expression
    over each (+ 1) (Second3 1 :: Either3 Int Int Int)Second3 2
    Example1 expression
    toListOf each (First3 1 :: Either3 Int Int Int)[1]
  • Injection1 (Either3 a b c) (Either3 a' b c) a a'Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    (First3 1 :: Either3 Int Bool String) ^? _I1Just 1
    Example1 expression
    over _I1 show (First3 1 :: Either3 Int Bool String)First3 "1"
  • Injection2 (Either3 a b c) (Either3 a b' c) b b'Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    (Second3 True :: Either3 Int Bool String) ^? _I2Just True
    Example1 expression
    _I2 # True :: Either3 Int Bool StringSecond3 True
  • Injection3 (Either3 a b c) (Either3 a b c') c c'Defined in either-n-0.1.0.0 · Data.Either3.Either3
    Example1 expression
    (Third3 "x" :: Either3 Int Bool String) ^? _I3Just "x"
    Example1 expression
    (First3 1 :: Either3 Int Bool String) ^? _I3Nothing
  • type Rep (Either3 a b c) = D1 ('MetaData "Either3" "Data.Either3.Either3" "either-n-0.1.0.0-LvChQUrDWnAFO3PERucv7g" 'False) (C1 ('MetaCons "First3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "Second3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)) :+: C1 ('MetaCons "Third3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c))))Defined in either-n-0.1.0.0 · Data.Either3.Either3
  • type Rep1 (Either3 a b) = D1 ('MetaData "Either3" "Data.Either3.Either3" "either-n-0.1.0.0-LvChQUrDWnAFO3PERucv7g" 'False) (C1 ('MetaCons "First3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "Second3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)) :+: C1 ('MetaCons "Third3" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)))Defined in either-n-0.1.0.0 · Data.Either3.Either3

Catamorphism

1 declaration
valuefoldEither3 :: (a -> x) -> (b -> x) -> (c -> x) -> Either3 a b c -> x
#

Case analysis for Either3.

Example1 expression
foldEither3 length fromEnum (+ 1) (First3 "abc" :: Either3 String Bool Int)3
Example1 expression
foldEither3 length (const 0) (+ 1) (Third3 1 :: Either3 String Bool Int)2

Isomorphisms

5 declarations
valueeither3ACB
  1. :: (Profunctor p, Functor f)
  2. => p (Either3 a c b) (f (Either3 a' c' b'))
  3. -> p (Either3 a b c) (f (Either3 a' b' c'))
#

Reorder the type parameters of Either3 to a c b.

Example1 expression
view either3ACB (Second3 True :: Either3 String Bool Int)Third3 True
Example1 expression
view either3ACB (Third3 1 :: Either3 String Bool Int)Second3 1
Example1 expression
over either3ACB (bimap show not) (Second3 True :: Either3 String Bool Int)Second3 False
valueeither3BAC
  1. :: (Profunctor p, Functor f)
  2. => p (Either3 b a c) (f (Either3 b' a' c'))
  3. -> p (Either3 a b c) (f (Either3 a' b' c'))
#

Reorder the type parameters of Either3 to b a c.

Example1 expression
view either3BAC (First3 "x" :: Either3 String Bool Int)Second3 "x"
Example1 expression
view either3BAC (Second3 True :: Either3 String Bool Int)First3 True
valueeither3BCA
  1. :: (Profunctor p, Functor f)
  2. => p (Either3 b c a) (f (Either3 b' c' a'))
  3. -> p (Either3 a b c) (f (Either3 a' b' c'))
#

Reorder the type parameters of Either3 to b c a.

Example1 expression
view either3BCA (First3 "x" :: Either3 String Bool Int)Third3 "x"
Example1 expression
view either3BCA (Second3 True :: Either3 String Bool Int)First3 True
Example1 expression
review either3BCA (First3 True :: Either3 Bool Int String)Second3 True
valueeither3CAB
  1. :: (Profunctor p, Functor f)
  2. => p (Either3 c a b) (f (Either3 c' a' b'))
  3. -> p (Either3 a b c) (f (Either3 a' b' c'))
#

Reorder the type parameters of Either3 to c a b.

Example1 expression
view either3CAB (First3 "x" :: Either3 String Bool Int)Second3 "x"
Example1 expression
view either3CAB (Third3 1 :: Either3 String Bool Int)First3 1
Example1 expression
review either3CAB (First3 1 :: Either3 Int String Bool)Third3 1
valueeither3CBA
  1. :: (Profunctor p, Functor f)
  2. => p (Either3 c b a) (f (Either3 c' b' a'))
  3. -> p (Either3 a b c) (f (Either3 a' b' c'))
#

Reorder the type parameters of Either3 to c b a.

Example1 expression
view either3CBA (First3 "x" :: Either3 String Bool Int)Third3 "x"
Example1 expression
view either3CBA (Second3 True :: Either3 String Bool Int)Second3 True

Optics

0 declarations

Classy lenses

classclass GetEither3 s a b c | s -> a b c where
#

Class for types that can be viewed as an Either3.

Example1 expression
view getEither3 (Third3 1 :: Either3 String Bool Int)Third3 1

Methods

Instances2GetEither3
  • GetEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • GetEither3 (Either3T Identity a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3T
    Example1 expression
    view getEither3 (e3 (Third3 1))Third3 1
classclass GetEither3 s a b c => HasEither3 s a b c | s -> a b c where
#

Class for types that have a Lens' to an Either3. Instances define setEither3; the lens either3 follows from it and from getEither3.

Example1 expression
setEither3 (Second3 True) (Third3 1 :: Either3 String Bool Int)Second3 True
Example1 expression
over either3 (fmap (+ 1)) (Third3 1 :: Either3 String Bool Int)Third3 2

Methods

Instances2HasEither3
  • HasEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • HasEither3 (Either3T Identity a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3T
    Example1 expression
    setEither3 (Second3 True) (e3 (Third3 1))Either3T (Identity (Second3 True))

Classy prisms

classclass ReviewEither3 t a b c | t -> a b c where
#

Class for types that can be constructed from an Either3.

Example1 expression
review reviewEither3 (First3 "x") :: Either3 String Bool IntFirst3 "x"

Methods

Instances2ReviewEither3
  • ReviewEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • Applicative f => ReviewEither3 (Either3T f a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3T

    Any Either3 can be put in an Applicative f.

    Example1 expression
    review reviewEither3 (Second3 True) :: Either3TMaybe String Bool IntEither3T (Just (Second3 True))
classclass ReviewEither3 t a b c => AsEither3 t a b c | t -> a b c where
#

Class for types that have a Prism' to an Either3. Instances define matchEither3; the prism _Either3 follows from it and from reviewEither3.

Example1 expression
matchEither3 (Third3 1 :: Either3 String Bool Int)Just (Third3 1)
Example1 expression
(Third3 1 :: Either3 String Bool Int) ^? _Either3Just (Third3 1)

Methods

Instances2AsEither3
  • AsEither3 (Either3 a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3
  • AsEither3 (Either3T Identity a b c) a b cDefined in either-n-0.1.0.0 · Data.Either3.Either3T
    Example1 expression
    matchEither3 (e3 (Third3 1))Just (Third3 1)
    Example1 expression
    e3 (Third3 1) ^? _Either3Just (Third3 1)