accelerate-1.2.0.1: An embedded language for accelerated array processing

Copyright [2018] Trevor L. McDonell BSD3 Trevor L. McDonell experimental non-portable (GHC extensions) None Haskell2010

Data.Array.Accelerate.Data.Either

Contents

Description

Since: accelerate-1.2.0.0

Synopsis

# Documentation

data Either a b #

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
 Since: base-4.8.0.0 Instance detailsDefined in Data.Bifunctor Methodsbimap :: (a -> b) -> (c -> d) -> Either a c -> Either b d #first :: (a -> b) -> Either a c -> Either b c #second :: (b -> c) -> Either a b -> Either a c # 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 # 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 # 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) #liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Either a b] #liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Either a b) #liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Either a b] # 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 #liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Either a b] -> ShowS # Since: deepseq-1.4.3.0 Instance detailsDefined in Control.DeepSeq MethodsliftRnf2 :: (a -> ()) -> (b -> ()) -> Either a b -> () # Instance detailsDefined in Data.Hashable.Class MethodsliftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Either a b -> Int # Instance detailsDefined in Data.Semigroup.Traversable.Class Methodsbitraverse1 :: Apply f => (a -> f b) -> (c -> f d) -> Either a c -> f (Either b d) #bisequence1 :: Apply f => Either (f a) (f b) -> f (Either a b) # Instance detailsDefined in Control.Lens.Iso Methodsswapped :: (Profunctor p, Functor f) => p (Either b a) (f (Either d c)) -> p (Either a b) (f (Either c d)) # () :=> (Monad (Either a)) Instance detailsDefined in Data.Constraint Methodsins :: () :- Monad (Either a) # () :=> (Functor (Either a)) Instance detailsDefined in Data.Constraint Methodsins :: () :- Functor (Either a) # () :=> (Applicative (Either a)) Instance detailsDefined in Data.Constraint Methodsins :: () :- Applicative (Either a) # (Lift Exp a, Lift Exp b, Elt (Plain a), Elt (Plain b)) => Lift Exp (Either a b) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either Associated Typestype Plain (Either a b) :: * Source # Methodslift :: Either a b -> Exp (Plain (Either a b)) 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 #(>>) :: Either e a -> Either e b -> Either e b #return :: a -> Either e a #fail :: String -> Either e a # Since: base-3.0 Instance detailsDefined in Data.Either Methodsfmap :: (a0 -> b) -> Either a a0 -> Either a b #(<$) :: a0 -> Either a b -> Either a a0 # Since: base-4.3.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Either e a) -> Either e a # Since: base-3.0 Instance detailsDefined in Data.Either Methodspure :: a -> Either e a #(<*>) :: Either e (a -> b) -> Either e a -> Either e b #liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c #(*>) :: Either e a -> Either e b -> Either e b #(<*) :: Either e a -> Either e b -> Either e a # Since: base-4.7.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => Either a m -> m #foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m #foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b #foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b #foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b #foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b #foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 #foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 #toList :: Either a a0 -> [a0] #null :: Either a a0 -> Bool #length :: Either a a0 -> Int #elem :: Eq a0 => a0 -> Either a a0 -> Bool #maximum :: Ord a0 => Either a a0 -> a0 #minimum :: Ord a0 => Either a a0 -> a0 #sum :: Num a0 => Either a a0 -> a0 #product :: Num a0 => Either a a0 -> a0 # Since: base-4.7.0.0 Instance detailsDefined in Data.Traversable Methodstraverse :: Applicative f => (a0 -> f b) -> Either a a0 -> f (Either a b) #sequenceA :: Applicative f => Either a (f a0) -> f (Either a a0) #mapM :: Monad m => (a0 -> m b) -> Either a a0 -> m (Either a b) #sequence :: Monad m => Either a (m a0) -> m (Either a a0) # (Elt a, Elt b) => Semigroup (Exp (Either a b)) # Instance detailsDefined in Data.Array.Accelerate.Data.Either Methods(<>) :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) #sconcat :: NonEmpty (Exp (Either a b)) -> Exp (Either a b) #stimes :: Integral b0 => b0 -> Exp (Either a b) -> Exp (Either a b) # 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 # 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 # 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) #liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Either a a0] #liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Either a a0) #liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Either a a0] # 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 #liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Either a a0] -> ShowS # Instance detailsDefined in Basement.Monad Associated Typestype Failure (Either a) :: * # MethodsmFail :: Failure (Either a) -> Either a () # e ~ SomeException => MonadMask (Either e) Since: exceptions-0.8.3 Instance detailsDefined in Control.Monad.Catch Methodsmask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b #uninterruptibleMask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b #generalBracket :: Either e a -> (a -> ExitCase b -> Either e c) -> (a -> Either e b) -> Either e (b, c) # e ~ SomeException => MonadCatch (Either e) Since: exceptions-0.8.3 Instance detailsDefined in Control.Monad.Catch Methodscatch :: Exception e0 => Either e a -> (e0 -> Either e a) -> Either e a # e ~ SomeException => MonadThrow (Either e) Instance detailsDefined in Control.Monad.Catch MethodsthrowM :: Exception e0 => e0 -> Either e a # NFData a => NFData1 (Either a) Since: deepseq-1.4.3.0 Instance detailsDefined in Control.DeepSeq MethodsliftRnf :: (a0 -> ()) -> Either a a0 -> () # Hashable a => Hashable1 (Either a) Instance detailsDefined in Data.Hashable.Class MethodsliftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Either a a0 -> Int # Elt a => Functor (Either a) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either Methodsfmap :: (Elt a0, Elt b, Elt (Either a a0), Elt (Either a b)) => (Exp a0 -> Exp b) -> Exp (Either a a0) -> Exp (Either a b) Source #(<$) :: (Elt a0, Elt b, Elt (Either a a0), Elt (Either a b)) => Exp a0 -> Exp (Either a b) -> Exp (Either a a0) Source # Generic1 (Either a :: * -> *) Instance detailsDefined in GHC.Generics Associated Typestype Rep1 (Either a) :: k -> * # Methodsfrom1 :: Either a a0 -> Rep1 (Either a) a0 #to1 :: Rep1 (Either a) a0 -> Either a a0 # MonadBaseControl (Either e) (Either e) Instance detailsDefined in Control.Monad.Trans.Control Associated Typestype StM (Either e) a :: * # MethodsliftBaseWith :: (RunInBase (Either e) (Either e) -> Either e a) -> Either e a #restoreM :: StM (Either e) a -> Either e a # (Eq a, Eq b) => Eq (Either a b) Instance detailsDefined in Data.Either Methods(==) :: Either a b -> Either a b -> Bool #(/=) :: Either a b -> Either a b -> Bool # (Ord a, Ord b) => Ord (Either a b) Instance detailsDefined in Data.Either Methodscompare :: Either a b -> Either a b -> Ordering #(<) :: Either a b -> Either a b -> Bool #(<=) :: Either a b -> Either a b -> Bool #(>) :: Either a b -> Either a b -> Bool #(>=) :: Either a b -> Either a b -> Bool #max :: Either a b -> Either a b -> Either a b #min :: Either a b -> Either a b -> Either a b # (Read a, Read b) => Read (Either a b) Instance detailsDefined in Data.Either MethodsreadsPrec :: Int -> ReadS (Either a b) #readList :: ReadS [Either a b] #readPrec :: ReadPrec (Either a b) #readListPrec :: ReadPrec [Either a b] # (Show a, Show b) => Show (Either a b) Instance detailsDefined in Data.Either MethodsshowsPrec :: Int -> Either a b -> ShowS #show :: Either a b -> String #showList :: [Either a b] -> ShowS # Generic (Either a b) Instance detailsDefined in GHC.Generics Associated Typestype Rep (Either a b) :: * -> * # Methodsfrom :: Either a b -> Rep (Either a b) x #to :: Rep (Either a b) x -> Either a b # 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 #sconcat :: NonEmpty (Either a b) -> Either a b #stimes :: Integral b0 => b0 -> Either a b -> Either a b # (Lift a, Lift b) => Lift (Either a b) Instance detailsDefined in Language.Haskell.TH.Syntax Methodslift :: Either a b -> Q Exp # (NFData a, NFData b) => NFData (Either a b) Instance detailsDefined in Control.DeepSeq Methodsrnf :: Either a b -> () # (Hashable a, Hashable b) => Hashable (Either a b) Instance detailsDefined in Data.Hashable.Class MethodshashWithSalt :: Int -> Either a b -> Int #hash :: Either a b -> Int # (Elt a, Elt b) => Elt (Either a b) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either MethodseltType :: Either a b -> TupleType (EltRepr (Either a b))fromElt :: Either a b -> EltRepr (Either a b)toElt :: EltRepr (Either a b) -> Either a b (Eq a, Eq b) => Eq (Either a b) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either Methods(==) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(/=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source # (Ord a, Ord b) => Ord (Either a b) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either Methods(<) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(>) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(<=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(>=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #min :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) Source #max :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) Source #compare :: Exp (Either a b) -> Exp (Either a b) -> Exp Ordering Source # (Eq a, Eq b) :=> (Eq (Either a b)) Instance detailsDefined in Data.Constraint Methodsins :: (Eq a, Eq b) :- Eq (Either a b) # (Ord a, Ord b) :=> (Ord (Either a b)) Instance detailsDefined in Data.Constraint Methodsins :: (Ord a, Ord b) :- Ord (Either a b) # (Read a, Read b) :=> (Read (Either a b)) Instance detailsDefined in Data.Constraint Methodsins :: (Read a, Read b) :- Read (Either a b) # (Show a, Show b) :=> (Show (Either a b)) Instance detailsDefined in Data.Constraint Methodsins :: (Show a, Show b) :- Show (Either a b) # (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 #imapped :: (Indexable (Either i j) p, Settable f0) => p a (f0 b) -> Sum f g a -> f0 (Sum f g b) # (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 #imapped :: (Indexable (Either i j) p, Settable f0) => p a (f0 b) -> Product f g a -> f0 (Product f g b) # (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 #imapped :: (Indexable (Either i j) p, Settable f0) => p a (f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) # (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 #imapped :: (Indexable (Either i j) p, Settable f0) => p a (f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) # (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 #ifolded :: (Indexable (Either i j) p, Contravariant f0, Applicative f0) => p a (f0 a) -> Sum f g a -> f0 (Sum f g a) #ifoldr :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b #ifoldl :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b #ifoldr' :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b #ifoldl' :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b # (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 #ifolded :: (Indexable (Either i j) p, Contravariant f0, Applicative f0) => p a (f0 a) -> Product f g a -> f0 (Product f g a) #ifoldr :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b #ifoldl :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b #ifoldr' :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b #ifoldl' :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b # (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 #ifolded :: (Indexable (Either i j) p, Contravariant f0, Applicative f0) => p a (f0 a) -> (f :+: g) a -> f0 ((f :+: g) a) #ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b #ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b #ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b #ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b # (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 #ifolded :: (Indexable (Either i j) p, Contravariant f0, Applicative f0) => p a (f0 a) -> (f :*: g) a -> f0 ((f :*: g) a) #ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b #ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b #ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b #ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b # (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) #itraversed :: (Indexable (Either i j) p, Applicative f0) => p a (f0 b) -> Sum f g a -> f0 (Sum f g b) # (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) #itraversed :: (Indexable (Either i j) p, Applicative f0) => p a (f0 b) -> Product f g a -> f0 (Product f g b) # (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) #itraversed :: (Indexable (Either i j) p, Applicative f0) => p a (f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) # (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) #itraversed :: (Indexable (Either i j) p, Applicative f0) => p a (f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) # 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 :: * -> *) Instance detailsDefined in GHC.Generics type Rep1 (Either a :: * -> *) = 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 Plain (Either a b) Source # Instance detailsDefined in Data.Array.Accelerate.Data.Either type Plain (Either a b) = Either (Plain a) (Plain b)

left :: forall a b. (Elt a, Elt b) => Exp a -> Exp (Either a b) Source #

Lift a value into the Left constructor

right :: forall a b. (Elt a, Elt b) => Exp b -> Exp (Either a b) Source #

Lift a value into the Right constructor

either :: (Elt a, Elt b, Elt c) => (Exp a -> Exp c) -> (Exp b -> Exp c) -> Exp (Either a b) -> Exp c Source #

The either function performs case analysis on the Either type. If the value is Left a, apply the first function to a; if it is Right b, apply the second function to b.

isLeft :: (Elt a, Elt b) => Exp (Either a b) -> Exp Bool Source #

Return True if the argument is a Left-value

isRight :: (Elt a, Elt b) => Exp (Either a b) -> Exp Bool Source #

Return True if the argument is a Right-value

fromLeft :: (Elt a, Elt b) => Exp (Either a b) -> Exp a Source #

The fromLeft function extracts the element out of the Left constructor. If the argument was actually Right, you will get an undefined value instead.

fromRight :: (Elt a, Elt b) => Exp (Either a b) -> Exp b Source #

The fromRight function extracts the element out of the Right constructor. If the argument was actually Left, you will get an undefined value instead.

lefts :: (Shape sh, Slice sh, Elt a, Elt b) => Acc (Array (sh :. Int) (Either a b)) -> Acc (Vector a, Array sh Int) Source #

Extract from the array of Either all of the Left elements, together with a segment descriptor indicating how many elements along each dimension were returned.

rights :: (Shape sh, Slice sh, Elt a, Elt b) => Acc (Array (sh :. Int) (Either a b)) -> Acc (Vector b, Array sh Int) Source #

Extract from the array of Either all of the Right elements, together with a segment descriptor indicating how many elements along each dimension were returned.

# Orphan instances

 (Lift Exp a, Lift Exp b, Elt (Plain a), Elt (Plain b)) => Lift Exp (Either a b) Source # Instance details Associated Typestype Plain (Either a b) :: * Source # Methodslift :: Either a b -> Exp (Plain (Either a b)) Source # (Elt a, Elt b) => Semigroup (Exp (Either a b)) Source # Instance details Methods(<>) :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) #sconcat :: NonEmpty (Exp (Either a b)) -> Exp (Either a b) #stimes :: Integral b0 => b0 -> Exp (Either a b) -> Exp (Either a b) # Elt a => Functor (Either a) Source # Instance details Methodsfmap :: (Elt a0, Elt b, Elt (Either a a0), Elt (Either a b)) => (Exp a0 -> Exp b) -> Exp (Either a a0) -> Exp (Either a b) Source #(<\$) :: (Elt a0, Elt b, Elt (Either a a0), Elt (Either a b)) => Exp a0 -> Exp (Either a b) -> Exp (Either a a0) Source # (Elt a, Elt b) => Elt (Either a b) Source # Instance details MethodseltType :: Either a b -> TupleType (EltRepr (Either a b))fromElt :: Either a b -> EltRepr (Either a b)toElt :: EltRepr (Either a b) -> Either a b (Eq a, Eq b) => Eq (Either a b) Source # Instance details Methods(==) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(/=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source # (Ord a, Ord b) => Ord (Either a b) Source # Instance details Methods(<) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(>) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(<=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #(>=) :: Exp (Either a b) -> Exp (Either a b) -> Exp Bool Source #min :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) Source #max :: Exp (Either a b) -> Exp (Either a b) -> Exp (Either a b) Source #compare :: Exp (Either a b) -> Exp (Either a b) -> Exp Ordering Source #