plutus-tx-0.1.0.0: Libraries for Plutus Tx and its prelude

PlutusTx.Either

Synopsis

# Documentation

data Either a b Source #

The Either type represents values with two possibilities: a value of type Either a b is either Left a or Right b.

The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").

#### Examples

Expand

The type Either String Int is the type of values which can be either a String or an Int. The Left constructor can be used only on Strings, and the Right constructor can be used only on Ints:

>>> let s = Left "foo" :: Either String Int
>>> s
Left "foo"
>>> let n = Right 3 :: Either String Int
>>> n
Right 3
>>> :type s
s :: Either String Int
>>> :type n
n :: Either String Int


The fmap from our Functor instance will ignore Left values, but will apply the supplied function to values contained in a Right:

>>> let s = Left "foo" :: Either String Int
>>> let n = Right 3 :: Either String Int
>>> fmap (*2) s
Left "foo"
>>> fmap (*2) n
Right 6


The Monad instance for Either allows us to chain together multiple actions which may fail, and fail overall if any of the individual steps failed. First we'll write a function that can either parse an Int from a Char, or fail.

>>> import Data.Char ( digitToInt, isDigit )
>>> :{
    let parseEither :: Char -> Either String Int
parseEither c
| isDigit c = Right (digitToInt c)
| otherwise = Left "parse error"
>>> :}


The following should work, since both '1' and '2' can be parsed as Ints.

>>> :{
    let parseMultiple :: Either String Int
parseMultiple = do
x <- parseEither '1'
y <- parseEither '2'
return (x + y)
>>> :}

>>> parseMultiple
Right 3


But the following should fail overall, since the first operation where we attempt to parse 'm' as an Int will fail:

>>> :{
    let parseMultiple :: Either String Int
parseMultiple = do
x <- parseEither 'm'
y <- parseEither '2'
return (x + y)
>>> :}

>>> parseMultiple
Left "parse error"


Constructors

 Left a Right b

#### Instances

Instances details
 Instance detailsDefined in Data.Aeson.Types.ToJSON MethodsliftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Either a b -> Value Source #liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Either a b] -> Value Source #liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Either a b -> Encoding Source #liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Either a b] -> Encoding Source # Instance detailsDefined in Data.Aeson.Types.FromJSON MethodsliftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Either a b) Source #liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Either a b] Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Bifunctor Methodsbimap :: (a -> b) -> (c -> d) -> Either a c -> Either b d Source #first :: (a -> b) -> Either a c -> Either b c Source #second :: (b -> c) -> Either a b -> Either a c Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Either a c -> Either b d -> Bool Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Either a c -> Either b d -> Ordering Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Either a b) Source #liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Either a b] Source #liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Either a b) Source #liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Either a b] Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Either a b -> ShowS Source #liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Either a b] -> ShowS Source # Since: deepseq-1.4.3.0 Instance detailsDefined in Control.DeepSeq MethodsliftRnf2 :: (a -> ()) -> (b -> ()) -> Either a b -> () Source # Instance detailsDefined in Data.Hashable.Class MethodsliftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Either a b -> Int Source # Instance detailsDefined in Data.Semigroup.Traversable.Class Methodsbitraverse1 :: Apply f => (a -> f b) -> (c -> f d) -> Either a c -> f (Either b d) Source #bisequence1 :: Apply f => Either (f a) (f b) -> f (Either a b) Source # Instance detailsDefined in Control.Lens.Iso Methodsswapped :: Iso (Either a b) (Either c d) (Either b a) (Either d c) Source # MonadError e (Either e) Instance detailsDefined in Control.Monad.Error.Class MethodsthrowError :: e -> Either e a Source #catchError :: Either e a -> (e -> Either e a) -> Either e a Source # (Lift a, Lift b) => Lift (Either a b :: Type) Instance detailsDefined in Language.Haskell.TH.Syntax Methodslift :: Either a b -> Q Exp Source #liftTyped :: Either a b -> Q (TExp (Either a b)) Source # Source # Instance detailsDefined in PlutusTx.Lift.Instances Methodslift :: Either a b -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) Source # Monad (Either e) Since: base-4.4.0.0 Instance detailsDefined in Data.Either Methods(>>=) :: Either e a -> (a -> Either e b) -> Either e b Source #(>>) :: Either e a -> Either e b -> Either e b Source #return :: a -> Either e a Source # Since: base-3.0 Instance detailsDefined in Data.Either Methodsfmap :: (a0 -> b) -> Either a a0 -> Either a b Source #(<\$) :: a0 -> Either a b -> Either a a0 Source # Since: base-4.3.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Either e a) -> Either e a Source # Since: base-3.0 Instance detailsDefined in Data.Either Methodspure :: a -> Either e a Source #(<*>) :: Either e (a -> b) -> Either e a -> Either e b Source #liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c Source #(*>) :: Either e a -> Either e b -> Either e b Source #(<*) :: Either e a -> Either e b -> Either e a Source # Since: base-4.7.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => Either a m -> m Source #foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source #foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source #foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source #foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source #foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source #foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source #foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source #foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source #toList :: Either a a0 -> [a0] Source #null :: Either a a0 -> Bool Source #length :: Either a a0 -> Int Source #elem :: Eq a0 => a0 -> Either a a0 -> Bool Source #maximum :: Ord a0 => Either a a0 -> a0 Source #minimum :: Ord a0 => Either a a0 -> a0 Source #sum :: Num a0 => Either a a0 -> a0 Source #product :: Num a0 => Either a a0 -> a0 Source # Since: base-4.7.0.0 Instance detailsDefined in Data.Traversable Methodstraverse :: Applicative f => (a0 -> f b) -> Either a a0 -> f (Either a b) Source #sequenceA :: Applicative f => Either a (f a0) -> f (Either a a0) Source #mapM :: Monad m => (a0 -> m b) -> Either a a0 -> m (Either a b) Source #sequence :: Monad m => Either a (m a0) -> m (Either a a0) Source # ToJSON a => ToJSON1 (Either a) Instance detailsDefined in Data.Aeson.Types.ToJSON MethodsliftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Either a a0 -> Value Source #liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Either a a0] -> Value Source #liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Either a a0 -> Encoding Source #liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Either a a0] -> Encoding Source # FromJSON a => FromJSON1 (Either a) Instance detailsDefined in Data.Aeson.Types.FromJSON MethodsliftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Either a a0) Source #liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Either a a0] Source # Eq a => Eq1 (Either a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftEq :: (a0 -> b -> Bool) -> Either a a0 -> Either a b -> Bool Source # Ord a => Ord1 (Either a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftCompare :: (a0 -> b -> Ordering) -> Either a a0 -> Either a b -> Ordering Source # Show a => Show1 (Either a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Either a a0 -> ShowS Source #liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Either a a0] -> ShowS Source # Read a => Read1 (Either a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Either a a0) Source #liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Either a a0] Source #liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Either a a0) Source #liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Either a a0] Source # Instance detailsDefined in Basement.Monad Associated Typestype Failure (Either a) Source # MethodsmFail :: Failure (Either a) -> Either a () Source # NFData a => NFData1 (Either a) Since: deepseq-1.4.3.0 Instance detailsDefined in Control.DeepSeq MethodsliftRnf :: (a0 -> ()) -> Either a a0 -> () Source # Hashable a => Hashable1 (Either a) Instance detailsDefined in Data.Hashable.Class MethodsliftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Either a a0 -> Int Source # Source # Instance detailsDefined in PlutusTx.Functor Methodsfmap :: (a -> b) -> Either c a -> Either c b Source # Source # Instance detailsDefined in PlutusTx.Applicative Methodspure :: a0 -> Either a a0 Source #(<*>) :: Either a (a0 -> b) -> Either a a0 -> Either a b Source # Source # Instance detailsDefined in PlutusTx.Foldable MethodsfoldMap :: Monoid m => (a -> m) -> Either c a -> m Source # Source # Instance detailsDefined in PlutusTx.Traversable Methodstraverse :: Applicative f => (a -> f b) -> Either c a -> f (Either c b) Source # Generic1 (Either a :: Type -> Type) Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Associated Typestype Rep1 (Either a) :: k -> Type Source # Methodsfrom1 :: forall (a0 :: k). Either a a0 -> Rep1 (Either a) a0 Source #to1 :: forall (a0 :: k). Rep1 (Either a) a0 -> Either a a0 Source # MonadBaseControl (Either e) (Either e) Instance detailsDefined in Control.Monad.Trans.Control Associated Typestype StM (Either e) a Source # MethodsliftBaseWith :: (RunInBase (Either e) (Either e) -> Either e a) -> Either e a Source #restoreM :: StM (Either e) a -> Either e a Source # (Eq a, Eq b) => Eq (Either a b) Since: base-2.1 Instance detailsDefined in Data.Either Methods(==) :: Either a b -> Either a b -> Bool Source #(/=) :: Either a b -> Either a b -> Bool Source # (Data a, Data b) => Data (Either a b) Since: base-4.0.0.0 Instance detailsDefined in Data.Data Methodsgfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Either a b -> c (Either a b) Source #gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Either a b) Source #toConstr :: Either a b -> Constr Source #dataTypeOf :: Either a b -> DataType Source #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Either a b)) Source #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Either a b)) Source #gmapT :: (forall b0. Data b0 => b0 -> b0) -> Either a b -> Either a b Source #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source #gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source #gmapQ :: (forall d. Data d => d -> u) -> Either a b -> [u] Source #gmapQi :: Int -> (forall d. Data d => d -> u) -> Either a b -> u Source #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source # (Ord a, Ord b) => Ord (Either a b) Since: base-2.1 Instance detailsDefined in Data.Either Methodscompare :: Either a b -> Either a b -> Ordering Source #(<) :: Either a b -> Either a b -> Bool Source #(<=) :: Either a b -> Either a b -> Bool Source #(>) :: Either a b -> Either a b -> Bool Source #(>=) :: Either a b -> Either a b -> Bool Source #max :: Either a b -> Either a b -> Either a b Source #min :: Either a b -> Either a b -> Either a b Source # (Read a, Read b) => Read (Either a b) Since: base-3.0 Instance detailsDefined in Data.Either MethodsreadsPrec :: Int -> ReadS (Either a b) Source #readList :: ReadS [Either a b] Source # (Show a, Show b) => Show (Either a b) Since: base-3.0 Instance detailsDefined in Data.Either MethodsshowsPrec :: Int -> Either a b -> ShowS Source #show :: Either a b -> String Source #showList :: [Either a b] -> ShowS Source # Generic (Either a b) Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Associated Typestype Rep (Either a b) :: Type -> Type Source # Methodsfrom :: Either a b -> Rep (Either a b) x Source #to :: Rep (Either a b) x -> Either a b Source # Semigroup (Either a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Either Methods(<>) :: Either a b -> Either a b -> Either a b Source #sconcat :: NonEmpty (Either a b) -> Either a b Source #stimes :: Integral b0 => b0 -> Either a b -> Either a b Source # (Hashable a, Hashable b) => Hashable (Either a b) Instance detailsDefined in Data.Hashable.Class MethodshashWithSalt :: Int -> Either a b -> Int Source #hash :: Either a b -> Int Source # (ToJSON a, ToJSON b) => ToJSON (Either a b) Instance detailsDefined in Data.Aeson.Types.ToJSON MethodstoJSON :: Either a b -> Value Source #toEncoding :: Either a b -> Encoding Source #toJSONList :: [Either a b] -> Value Source #toEncodingList :: [Either a b] -> Encoding Source # (FromJSON a, FromJSON b) => FromJSON (Either a b) Instance detailsDefined in Data.Aeson.Types.FromJSON MethodsparseJSON :: Value -> Parser (Either a b) Source # (NFData a, NFData b) => NFData (Either a b) Instance detailsDefined in Control.DeepSeq Methodsrnf :: Either a b -> () Source # MonoFunctor (Either a b) Instance detailsDefined in Data.MonoTraversable Methodsomap :: (Element (Either a b) -> Element (Either a b)) -> Either a b -> Either a b Source # MonoFoldable (Either a b) Instance detailsDefined in Data.MonoTraversable MethodsofoldMap :: Monoid m => (Element (Either a b) -> m) -> Either a b -> m Source #ofoldr :: (Element (Either a b) -> b0 -> b0) -> b0 -> Either a b -> b0 Source #ofoldl' :: (a0 -> Element (Either a b) -> a0) -> a0 -> Either a b -> a0 Source #otoList :: Either a b -> [Element (Either a b)] Source #oall :: (Element (Either a b) -> Bool) -> Either a b -> Bool Source #oany :: (Element (Either a b) -> Bool) -> Either a b -> Bool Source #onull :: Either a b -> Bool Source #olength :: Either a b -> Int Source #olength64 :: Either a b -> Int64 Source #ocompareLength :: Integral i => Either a b -> i -> Ordering Source #otraverse_ :: Applicative f => (Element (Either a b) -> f b0) -> Either a b -> f () Source #ofor_ :: Applicative f => Either a b -> (Element (Either a b) -> f b0) -> f () Source #omapM_ :: Applicative m => (Element (Either a b) -> m ()) -> Either a b -> m () Source #oforM_ :: Applicative m => Either a b -> (Element (Either a b) -> m ()) -> m () Source #ofoldlM :: Monad m => (a0 -> Element (Either a b) -> m a0) -> a0 -> Either a b -> m a0 Source #ofoldMap1Ex :: Semigroup m => (Element (Either a b) -> m) -> Either a b -> m Source #ofoldr1Ex :: (Element (Either a b) -> Element (Either a b) -> Element (Either a b)) -> Either a b -> Element (Either a b) Source #ofoldl1Ex' :: (Element (Either a b) -> Element (Either a b) -> Element (Either a b)) -> Either a b -> Element (Either a b) Source #headEx :: Either a b -> Element (Either a b) Source #lastEx :: Either a b -> Element (Either a b) Source #unsafeHead :: Either a b -> Element (Either a b) Source #unsafeLast :: Either a b -> Element (Either a b) Source #maximumByEx :: (Element (Either a b) -> Element (Either a b) -> Ordering) -> Either a b -> Element (Either a b) Source #minimumByEx :: (Element (Either a b) -> Element (Either a b) -> Ordering) -> Either a b -> Element (Either a b) Source #oelem :: Element (Either a b) -> Either a b -> Bool Source #onotElem :: Element (Either a b) -> Either a b -> Bool Source # Instance detailsDefined in Data.MonoTraversable Methodsotraverse :: Applicative f => (Element (Either a b) -> f (Element (Either a b))) -> Either a b -> f (Either a b) Source #omapM :: Applicative m => (Element (Either a b) -> m (Element (Either a b))) -> Either a b -> m (Either a b) Source # MonoPointed (Either a b) Instance detailsDefined in Data.MonoTraversable Methodsopoint :: Element (Either a b) -> Either a b Source # Recursive (Either a b) Instance detailsDefined in Data.Functor.Foldable Methodsproject :: Either a b -> Base (Either a b) (Either a b) Source #cata :: (Base (Either a b) a0 -> a0) -> Either a b -> a0 Source #para :: (Base (Either a b) (Either a b, a0) -> a0) -> Either a b -> a0 Source #gpara :: (Corecursive (Either a b), Comonad w) => (forall b0. Base (Either a b) (w b0) -> w (Base (Either a b) b0)) -> (Base (Either a b) (EnvT (Either a b) w a0) -> a0) -> Either a b -> a0 Source #prepro :: Corecursive (Either a b) => (forall b0. Base (Either a b) b0 -> Base (Either a b) b0) -> (Base (Either a b) a0 -> a0) -> Either a b -> a0 Source #gprepro :: (Corecursive (Either a b), Comonad w) => (forall b0. Base (Either a b) (w b0) -> w (Base (Either a b) b0)) -> (forall c. Base (Either a b) c -> Base (Either a b) c) -> (Base (Either a b) (w a0) -> a0) -> Either a b -> a0 Source # Corecursive (Either a b) Instance detailsDefined in Data.Functor.Foldable Methodsembed :: Base (Either a b) (Either a b) -> Either a b Source #ana :: (a0 -> Base (Either a b) a0) -> a0 -> Either a b Source #apo :: (a0 -> Base (Either a b) (Either (Either a b) a0)) -> a0 -> Either a b Source #postpro :: Recursive (Either a b) => (forall b0. Base (Either a b) b0 -> Base (Either a b) b0) -> (a0 -> Base (Either a b) a0) -> a0 -> Either a b Source #gpostpro :: (Recursive (Either a b), Monad m) => (forall b0. m (Base (Either a b) b0) -> Base (Either a b) (m b0)) -> (forall c. Base (Either a b) c -> Base (Either a b) c) -> (a0 -> Base (Either a b) (m a0)) -> a0 -> Either a b Source # (Serialise a, Serialise b) => Serialise (Either a b) Since: serialise-0.2.0.0 Instance detailsDefined in Codec.Serialise.Class Methodsencode :: Either a b -> Encoding Source #decode :: Decoder s (Either a b) Source #encodeList :: [Either a b] -> Encoding Source #decodeList :: Decoder s [Either a b] Source # (Eq a, Eq b) => Eq (Either a b) Source # Instance detailsDefined in PlutusTx.Eq Methods(==) :: Either a b -> Either a b -> Bool Source # (Ord a, Ord b) => Ord (Either a b) Source # Instance detailsDefined in PlutusTx.Ord Methodscompare :: Either a b -> Either a b -> Ordering Source #(<) :: Either a b -> Either a b -> Bool Source #(<=) :: Either a b -> Either a b -> Bool Source #(>) :: Either a b -> Either a b -> Bool Source #(>=) :: Either a b -> Either a b -> Bool Source #max :: Either a b -> Either a b -> Either a b Source #min :: Either a b -> Either a b -> Either a b Source # (UnsafeFromData a, UnsafeFromData b) => UnsafeFromData (Either a b) Source # Instance detailsDefined in PlutusTx.IsData.Instances Methods (FromData a, FromData b) => FromData (Either a b) Source # Instance detailsDefined in PlutusTx.IsData.Instances Methods (ToData a, ToData b) => ToData (Either a b) Source # Instance detailsDefined in PlutusTx.IsData.Instances Methods Source # Instance detailsDefined in PlutusTx.Lift.Instances Methods (a ~ a', b ~ b') => Each (Either a a') (Either b b') a b each :: Traversal (Either a a) (Either b b) a bSince: lens-4.18 Instance detailsDefined in Control.Lens.Each Methodseach :: Traversal (Either a a') (Either b b') a b Source # (a ~ a', b ~ b') => Each (Either a a') (Either b b') a b Since: microlens-0.4.11 Instance detailsDefined in Lens.Micro.Internal Methodseach :: Traversal (Either a a') (Either b b') a b Source # (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Sum f g) Instance detailsDefined in Control.Lens.Indexed Methodsimap :: (Either i j -> a -> b) -> Sum f g a -> Sum f g b Source #imapped :: IndexedSetter (Either i j) (Sum f g a) (Sum f g b) a b Source # (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Product f g) Instance detailsDefined in Control.Lens.Indexed Methodsimap :: (Either i j -> a -> b) -> Product f g a -> Product f g b Source #imapped :: IndexedSetter (Either i j) (Product f g a) (Product f g b) a b Source # (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :+: g) Instance detailsDefined in Control.Lens.Indexed Methodsimap :: (Either i j -> a -> b) -> (f :+: g) a -> (f :+: g) b Source #imapped :: IndexedSetter (Either i j) ((f :+: g) a) ((f :+: g) b) a b Source # (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :*: g) Instance detailsDefined in Control.Lens.Indexed Methodsimap :: (Either i j -> a -> b) -> (f :*: g) a -> (f :*: g) b Source #imapped :: IndexedSetter (Either i j) ((f :*: g) a) ((f :*: g) b) a b Source # (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Sum f g) Instance detailsDefined in Control.Lens.Indexed MethodsifoldMap :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m Source #ifolded :: IndexedFold (Either i j) (Sum f g a) a Source #ifoldr :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b Source #ifoldl :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b Source #ifoldr' :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b Source #ifoldl' :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b Source # (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Product f g) Instance detailsDefined in Control.Lens.Indexed MethodsifoldMap :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m Source #ifolded :: IndexedFold (Either i j) (Product f g a) a Source #ifoldr :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b Source #ifoldl :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b Source #ifoldr' :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b Source #ifoldl' :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b Source # (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g) Instance detailsDefined in Control.Lens.Indexed MethodsifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m Source #ifolded :: IndexedFold (Either i j) ((f :+: g) a) a Source #ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b Source #ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b Source #ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b Source #ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b Source # (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :*: g) Instance detailsDefined in Control.Lens.Indexed MethodsifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m Source #ifolded :: IndexedFold (Either i j) ((f :*: g) a) a Source #ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b Source #ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b Source #ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b Source #ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b Source # (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Sum f g) Instance detailsDefined in Control.Lens.Indexed Methodsitraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> Sum f g a -> f0 (Sum f g b) Source #itraversed :: IndexedTraversal (Either i j) (Sum f g a) (Sum f g b) a b Source # (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Product f g) Instance detailsDefined in Control.Lens.Indexed Methodsitraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> Product f g a -> f0 (Product f g b) Source #itraversed :: IndexedTraversal (Either i j) (Product f g a) (Product f g b) a b Source # (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :+: g) Instance detailsDefined in Control.Lens.Indexed Methodsitraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) Source #itraversed :: IndexedTraversal (Either i j) ((f :+: g) a) ((f :+: g) b) a b Source # (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :*: g) Instance detailsDefined in Control.Lens.Indexed Methodsitraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) Source #itraversed :: IndexedTraversal (Either i j) ((f :*: g) a) ((f :*: g) b) a b Source # type Failure (Either a) Instance detailsDefined in Basement.Monad type Failure (Either a) = a type StM (Either e) a Instance detailsDefined in Control.Monad.Trans.Control type StM (Either e) a = a type Rep1 (Either a :: Type -> Type) Instance detailsDefined in GHC.Generics type Rep1 (Either a :: Type -> Type) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) type Rep (Either a b) Instance detailsDefined in GHC.Generics type Rep (Either a b) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b))) type Element (Either a b) Instance detailsDefined in Data.MonoTraversable type Element (Either a b) = b type Base (Either a b) Example boring stub for non-recursive data types Instance detailsDefined in Data.Functor.Foldable type Base (Either a b) = Const (Either a b) :: Type -> Type

isLeft :: Either a b -> Bool Source #

Return True if the given value is a Left-value, False otherwise.

isRight :: Either a b -> Bool Source #

Return True if the given value is a Right-value, False otherwise.

either :: (a -> c) -> (b -> c) -> Either a b -> c Source #

Plutus Tx version of either