Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Documentation
Choice
is a version of Either
that is strict on both the Left
side (called This
)
and the Right
side (called That
).
Note: Choice
is not used as an error monad. Use Fail
for that.
Bifunctor Choice Source # | |
Monad (Choice e) Source # | |
Functor (Choice a) Source # | |
Applicative (Choice e) Source # | |
(Eq b, Eq a) => Eq (Choice a b) Source # | |
(Data b, Data a) => Data (Choice a b) Source # | |
(Ord b, Ord a) => Ord (Choice a b) Source # | |
(Read b, Read a) => Read (Choice a b) Source # | |
(Show b, Show a) => Show (Choice a b) Source # | |
(Arbitrary a, Arbitrary b) => Arbitrary (Choice a b) Source # | |
(Hashable a, Hashable b) => Hashable (Choice a b) Source # | |
(NFData a, NFData b) => NFData (Choice a b) Source # | |
this :: Monad m => Choice a b -> m a Source #
>>>
this (This "foo") :: Maybe String
Just "foo"
>>>
this (That "bar") :: Maybe String
Nothing
that :: Monad m => Choice a b -> m b Source #
>>>
that (This "foo") :: Maybe String
Nothing
>>>
that (That "bar") :: Maybe String
Just "bar"
these :: [Choice a b] -> [a] Source #
>>>
these [This "foo", This "bar", That "baz", This "quux"]
["foo","bar","quux"]
those :: [Choice a b] -> [b] Source #
>>>
those [This "foo", This "bar", That "baz", This "quux"]
["baz"]
eitherToChoice :: Either a b -> Choice a b Source #
>>>
eitherToChoice (Left 1)
This 1
>>>
eitherToChoice (Right 5)
That 5
mergeChoice :: Choice a a -> a Source #
>>>
mergeChoice (This 5 :: Choice Int Int)
5
>>>
mergeChoice (That 'c' :: Choice Char Char)
'c'