{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE Safe #-} {-# LANGUAGE StrictData #-} module Network.MessagePack.Types.Result ( Result (..) ) where import Control.Applicative (Alternative (..), Applicative (..), (<$>), (<*>)) import Data.Foldable (Foldable) import Data.Traversable (Traversable) data Result a = Success a | Failure String deriving (ReadPrec [Result a] ReadPrec (Result a) Int -> ReadS (Result a) ReadS [Result a] (Int -> ReadS (Result a)) -> ReadS [Result a] -> ReadPrec (Result a) -> ReadPrec [Result a] -> Read (Result a) forall a. Read a => ReadPrec [Result a] forall a. Read a => ReadPrec (Result a) forall a. Read a => Int -> ReadS (Result a) forall a. Read a => ReadS [Result a] forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [Result a] $creadListPrec :: forall a. Read a => ReadPrec [Result a] readPrec :: ReadPrec (Result a) $creadPrec :: forall a. Read a => ReadPrec (Result a) readList :: ReadS [Result a] $creadList :: forall a. Read a => ReadS [Result a] readsPrec :: Int -> ReadS (Result a) $creadsPrec :: forall a. Read a => Int -> ReadS (Result a) Read, Int -> Result a -> ShowS [Result a] -> ShowS Result a -> String (Int -> Result a -> ShowS) -> (Result a -> String) -> ([Result a] -> ShowS) -> Show (Result a) forall a. Show a => Int -> Result a -> ShowS forall a. Show a => [Result a] -> ShowS forall a. Show a => Result a -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Result a] -> ShowS $cshowList :: forall a. Show a => [Result a] -> ShowS show :: Result a -> String $cshow :: forall a. Show a => Result a -> String showsPrec :: Int -> Result a -> ShowS $cshowsPrec :: forall a. Show a => Int -> Result a -> ShowS Show, Result a -> Result a -> Bool (Result a -> Result a -> Bool) -> (Result a -> Result a -> Bool) -> Eq (Result a) forall a. Eq a => Result a -> Result a -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Result a -> Result a -> Bool $c/= :: forall a. Eq a => Result a -> Result a -> Bool == :: Result a -> Result a -> Bool $c== :: forall a. Eq a => Result a -> Result a -> Bool Eq, a -> Result b -> Result a (a -> b) -> Result a -> Result b (forall a b. (a -> b) -> Result a -> Result b) -> (forall a b. a -> Result b -> Result a) -> Functor Result forall a b. a -> Result b -> Result a forall a b. (a -> b) -> Result a -> Result b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Result b -> Result a $c<$ :: forall a b. a -> Result b -> Result a fmap :: (a -> b) -> Result a -> Result b $cfmap :: forall a b. (a -> b) -> Result a -> Result b Functor, Result a -> Bool (a -> m) -> Result a -> m (a -> b -> b) -> b -> Result a -> b (forall m. Monoid m => Result m -> m) -> (forall m a. Monoid m => (a -> m) -> Result a -> m) -> (forall m a. Monoid m => (a -> m) -> Result a -> m) -> (forall a b. (a -> b -> b) -> b -> Result a -> b) -> (forall a b. (a -> b -> b) -> b -> Result a -> b) -> (forall b a. (b -> a -> b) -> b -> Result a -> b) -> (forall b a. (b -> a -> b) -> b -> Result a -> b) -> (forall a. (a -> a -> a) -> Result a -> a) -> (forall a. (a -> a -> a) -> Result a -> a) -> (forall a. Result a -> [a]) -> (forall a. Result a -> Bool) -> (forall a. Result a -> Int) -> (forall a. Eq a => a -> Result a -> Bool) -> (forall a. Ord a => Result a -> a) -> (forall a. Ord a => Result a -> a) -> (forall a. Num a => Result a -> a) -> (forall a. Num a => Result a -> a) -> Foldable Result forall a. Eq a => a -> Result a -> Bool forall a. Num a => Result a -> a forall a. Ord a => Result a -> a forall m. Monoid m => Result m -> m forall a. Result a -> Bool forall a. Result a -> Int forall a. Result a -> [a] forall a. (a -> a -> a) -> Result a -> a forall m a. Monoid m => (a -> m) -> Result a -> m forall b a. (b -> a -> b) -> b -> Result a -> b forall a b. (a -> b -> b) -> b -> Result a -> b forall (t :: * -> *). (forall m. Monoid m => t m -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. t a -> [a]) -> (forall a. t a -> Bool) -> (forall a. t a -> Int) -> (forall a. Eq a => a -> t a -> Bool) -> (forall a. Ord a => t a -> a) -> (forall a. Ord a => t a -> a) -> (forall a. Num a => t a -> a) -> (forall a. Num a => t a -> a) -> Foldable t product :: Result a -> a $cproduct :: forall a. Num a => Result a -> a sum :: Result a -> a $csum :: forall a. Num a => Result a -> a minimum :: Result a -> a $cminimum :: forall a. Ord a => Result a -> a maximum :: Result a -> a $cmaximum :: forall a. Ord a => Result a -> a elem :: a -> Result a -> Bool $celem :: forall a. Eq a => a -> Result a -> Bool length :: Result a -> Int $clength :: forall a. Result a -> Int null :: Result a -> Bool $cnull :: forall a. Result a -> Bool toList :: Result a -> [a] $ctoList :: forall a. Result a -> [a] foldl1 :: (a -> a -> a) -> Result a -> a $cfoldl1 :: forall a. (a -> a -> a) -> Result a -> a foldr1 :: (a -> a -> a) -> Result a -> a $cfoldr1 :: forall a. (a -> a -> a) -> Result a -> a foldl' :: (b -> a -> b) -> b -> Result a -> b $cfoldl' :: forall b a. (b -> a -> b) -> b -> Result a -> b foldl :: (b -> a -> b) -> b -> Result a -> b $cfoldl :: forall b a. (b -> a -> b) -> b -> Result a -> b foldr' :: (a -> b -> b) -> b -> Result a -> b $cfoldr' :: forall a b. (a -> b -> b) -> b -> Result a -> b foldr :: (a -> b -> b) -> b -> Result a -> b $cfoldr :: forall a b. (a -> b -> b) -> b -> Result a -> b foldMap' :: (a -> m) -> Result a -> m $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Result a -> m foldMap :: (a -> m) -> Result a -> m $cfoldMap :: forall m a. Monoid m => (a -> m) -> Result a -> m fold :: Result m -> m $cfold :: forall m. Monoid m => Result m -> m Foldable, Functor Result Foldable Result Functor Result -> Foldable Result -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Result a -> f (Result b)) -> (forall (f :: * -> *) a. Applicative f => Result (f a) -> f (Result a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> Result a -> m (Result b)) -> (forall (m :: * -> *) a. Monad m => Result (m a) -> m (Result a)) -> Traversable Result (a -> f b) -> Result a -> f (Result b) forall (t :: * -> *). Functor t -> Foldable t -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> t a -> f (t b)) -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)) -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a)) -> Traversable t forall (m :: * -> *) a. Monad m => Result (m a) -> m (Result a) forall (f :: * -> *) a. Applicative f => Result (f a) -> f (Result a) forall (m :: * -> *) a b. Monad m => (a -> m b) -> Result a -> m (Result b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Result a -> f (Result b) sequence :: Result (m a) -> m (Result a) $csequence :: forall (m :: * -> *) a. Monad m => Result (m a) -> m (Result a) mapM :: (a -> m b) -> Result a -> m (Result b) $cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> Result a -> m (Result b) sequenceA :: Result (f a) -> f (Result a) $csequenceA :: forall (f :: * -> *) a. Applicative f => Result (f a) -> f (Result a) traverse :: (a -> f b) -> Result a -> f (Result b) $ctraverse :: forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Result a -> f (Result b) $cp2Traversable :: Foldable Result $cp1Traversable :: Functor Result Traversable) instance Applicative Result where pure :: a -> Result a pure = a -> Result a forall a. a -> Result a Success Success a -> b f <*> :: Result (a -> b) -> Result a -> Result b <*> Result a x = (a -> b) -> Result a -> Result b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap a -> b f Result a x Failure String msg <*> Result a _ = String -> Result b forall a. String -> Result a Failure String msg instance Alternative Result where empty :: Result a empty = String -> Result a forall a. String -> Result a Failure String "empty alternative" s :: Result a s@Success {} <|> :: Result a -> Result a -> Result a <|> Result a _ = Result a s Result a _ <|> Result a r = Result a r instance Monad Result where Success a x >>= :: Result a -> (a -> Result b) -> Result b >>= a -> Result b f = a -> Result b f a x Failure String msg >>= a -> Result b _ = String -> Result b forall a. String -> Result a Failure String msg return :: a -> Result a return = a -> Result a forall a. a -> Result a Success #if (MIN_VERSION_base(4,13,0)) instance MonadFail Result where #endif fail :: String -> Result a fail = String -> Result a forall a. String -> Result a Failure