either-result-0.1.0.0: ‘Result a’ is a wrapper of ‘Either String a’.

Safe HaskellNone
LanguageHaskell2010
Extensions
  • Cpp
  • DeriveFunctor
  • DeriveTraversable
  • DeriveFoldable
  • DeriveGeneric
  • DerivingStrategies
  • GeneralizedNewtypeDeriving
  • ExplicitNamespaces
  • PatternSynonyms

Data.Either.Result

Description

Result a is a wrapper of Either String a, but Result is an instance of MonadFail. A discussion about MonadFail of Either is https://gitlab.haskell.org/ghc/ghc/-/issues/12160.

Synopsis

Documentation

data Result a Source #

Result a is a wrapper of Either String a.

Instances
Monad Result Source # 
Instance details

Defined in Data.Either.Result

Methods

(>>=) :: Result a -> (a -> Result b) -> Result b #

(>>) :: Result a -> Result b -> Result b #

return :: a -> Result a #

fail :: String -> Result a #

Functor Result Source # 
Instance details

Defined in Data.Either.Result

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

MonadFail Result Source # 
Instance details

Defined in Data.Either.Result

Methods

fail :: String -> Result a #

Applicative Result Source # 
Instance details

Defined in Data.Either.Result

Methods

pure :: a -> Result a #

(<*>) :: Result (a -> b) -> Result a -> Result b #

liftA2 :: (a -> b -> c) -> Result a -> Result b -> Result c #

(*>) :: Result a -> Result b -> Result b #

(<*) :: Result a -> Result b -> Result a #

Foldable Result Source # 
Instance details

Defined in Data.Either.Result

Methods

fold :: Monoid m => Result m -> m #

foldMap :: Monoid m => (a -> m) -> Result a -> m #

foldr :: (a -> b -> b) -> b -> Result a -> b #

foldr' :: (a -> b -> b) -> b -> Result a -> b #

foldl :: (b -> a -> b) -> b -> Result a -> b #

foldl' :: (b -> a -> b) -> b -> Result a -> b #

foldr1 :: (a -> a -> a) -> Result a -> a #

foldl1 :: (a -> a -> a) -> Result a -> a #

toList :: Result a -> [a] #

null :: Result a -> Bool #

length :: Result a -> Int #

elem :: Eq a => a -> Result a -> Bool #

maximum :: Ord a => Result a -> a #

minimum :: Ord a => Result a -> a #

sum :: Num a => Result a -> a #

product :: Num a => Result a -> a #

Traversable Result Source # 
Instance details

Defined in Data.Either.Result

Methods

traverse :: Applicative f => (a -> f b) -> Result a -> f (Result b) #

sequenceA :: Applicative f => Result (f a) -> f (Result a) #

mapM :: Monad m => (a -> m b) -> Result a -> m (Result b) #

sequence :: Monad m => Result (m a) -> m (Result a) #

Alternative Result Source # 
Instance details

Defined in Data.Either.Result

Methods

empty :: Result a #

(<|>) :: Result a -> Result a -> Result a #

some :: Result a -> Result [a] #

many :: Result a -> Result [a] #

MonadPlus Result Source # 
Instance details

Defined in Data.Either.Result

Methods

mzero :: Result a #

mplus :: Result a -> Result a -> Result a #

Eq a => Eq (Result a) Source # 
Instance details

Defined in Data.Either.Result

Methods

(==) :: Result a -> Result a -> Bool #

(/=) :: Result a -> Result a -> Bool #

Ord a => Ord (Result a) Source # 
Instance details

Defined in Data.Either.Result

Methods

compare :: Result a -> Result a -> Ordering #

(<) :: Result a -> Result a -> Bool #

(<=) :: Result a -> Result a -> Bool #

(>) :: Result a -> Result a -> Bool #

(>=) :: Result a -> Result a -> Bool #

max :: Result a -> Result a -> Result a #

min :: Result a -> Result a -> Result a #

Read a => Read (Result a) Source # 
Instance details

Defined in Data.Either.Result

Show a => Show (Result a) Source # 
Instance details

Defined in Data.Either.Result

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

Generic (Result a) Source # 
Instance details

Defined in Data.Either.Result

Associated Types

type Rep (Result a) :: Type -> Type #

Methods

from :: Result a -> Rep (Result a) x #

to :: Rep (Result a) x -> Result a #

Semigroup (Result a) Source # 
Instance details

Defined in Data.Either.Result

Methods

(<>) :: Result a -> Result a -> Result a #

sconcat :: NonEmpty (Result a) -> Result a #

stimes :: Integral b => b -> Result a -> Result a #

Monoid (Result a) Source # 
Instance details

Defined in Data.Either.Result

Methods

mempty :: Result a #

mappend :: Result a -> Result a -> Result a #

mconcat :: [Result a] -> Result a #

type Rep (Result a) Source # 
Instance details

Defined in Data.Either.Result

type Rep (Result a) = D1 (MetaData "Result" "Data.Either.Result" "either-result-0.1.0.0-3d133Bvk9dRBobYUljJ4mm" True) (C1 (MetaCons "Result" PrefixI True) (S1 (MetaSel (Just "either") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either String a))))

pattern Error :: String -> Result a Source #

Error means errors and failures etc.

pattern Success :: a -> Result a Source #

Success means successes and OKs etc.

result :: (String -> b) -> (a -> b) -> Result a -> b Source #

Case analysis for the Result type.

Examples

Expand
>>> let s = Success 0
>>> let e = Error "critical"
>>> result ("Bad: " ++) (("OK: " ++) . show) s
"OK: 0"
>>> result ("Bad: " ++) (("OK: " ++) . show) e
"Bad: critical"

toEither :: Result a -> Either String a Source #

Convert Either String a from Result a.

fromSuccess :: a -> Result a -> a Source #

Convert Result a to a with a default value.