selective-0.7.0.1: Selective applicative functors

Copyright | (c) Andrey Mokhov 2018-2024
License | MIT (see the file LICENSE)
Maintainer | andrey.mokhov@gmail.com
Stability | experimental
Safe Haskell | None
Language | Haskell2010

Control.Selective.Trans.Except

Description

This is a library for selective applicative functors, or just selective functors for short, an abstraction between applicative functors and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694.

This module defines a newtype around `ExceptT` from `transformers` with less restrictive `Applicative`, `Selective`, and `Alternative` implementations. It supplies an `instance `Selective` f => `Selective` (`ExceptT` e f)`, which makes `ExceptT` a bona-fide `Selective` transformer.

The API follows the API from the `transformers` package, so it can be used as a drop-in replacement. The documentation can be found in the `transformers` package.

Synopsis

- newtype ExceptT e (f :: Type -> Type) a = ExceptT {
  - unwrap :: ExceptT e f a
  }
- wrap :: forall e (m :: Type -> Type) a. ExceptT e m a -> ExceptT e m a
- type Except e = ExceptT e Identity
- except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a
- runExcept :: Except e a -> Either e a
- mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b
- withExcept :: (e -> e') -> Except e a -> Except e' a
- runExceptT :: ExceptT e m a -> m (Either e a)
- mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
- withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
- throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a
- catchE :: forall (m :: Type -> Type) e a e'. Monad m => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a
- liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b
- liftListen :: Monad m => Listen w m (Either e a) -> Listen w (ExceptT e m) a
- liftPass :: Monad m => Pass w m (Either e a) -> Pass w (ExceptT e m) a

# Documentation

newtype ExceptT e (f :: Type -> Type) a Source #

A newtype wrapper around `ExceptT` from `transformers` that provides less restrictive `Applicative`, `Selective` and `Alternative` instances.

Constructors

ExceptT |

Fields

- unwrap :: ExceptT e f a

#### Instances

Instances details

(Selective f, MonadIO f) => MonadIO (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods liftIO :: IO a -> ExceptT e f a Source #
(Selective f, MonadZip f) => MonadZip (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods mzip :: ExceptT e f a -> ExceptT e f b -> ExceptT e f (a, b) Source # mzipWith :: (a -> b -> c) -> ExceptT e f a -> ExceptT e f b -> ExceptT e f c Source # munzip :: ExceptT e f (a, b) -> (ExceptT e f a, ExceptT e f b) Source #
(Eq1 f, Eq e) => Eq1 (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods liftEq :: (a -> b -> Bool) -> ExceptT e f a -> ExceptT e f b -> Bool Source #
(Ord1 f, Ord e) => Ord1 (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods liftCompare :: (a -> b -> Ordering) -> ExceptT e f a -> ExceptT e f b -> Ordering Source #
(Read1 f, Read e) => Read1 (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ExceptT e f a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ExceptT e f a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ExceptT e f a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ExceptT e f a] Source #
(Show1 f, Show e) => Show1 (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExceptT e f a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExceptT e f a] -> ShowS Source #
Contravariant f => Contravariant (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods contramap :: (a' -> a) -> ExceptT e f a -> ExceptT e f a' Source # (>$) :: b -> ExceptT e f b -> ExceptT e f a Source #
(Selective f, Monoid e) => Alternative (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods empty :: ExceptT e f a Source # (<|>) :: ExceptT e f a -> ExceptT e f a -> ExceptT e f a Source # some :: ExceptT e f a -> ExceptT e f [a] Source # many :: ExceptT e f a -> ExceptT e f [a] Source #
Selective f => Applicative (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods pure :: a -> ExceptT e f a Source # (<*>) :: ExceptT e f (a -> b) -> ExceptT e f a -> ExceptT e f b Source # liftA2 :: (a -> b -> c) -> ExceptT e f a -> ExceptT e f b -> ExceptT e f c Source # (*>) :: ExceptT e f a -> ExceptT e f b -> ExceptT e f b Source # (<*) :: ExceptT e f a -> ExceptT e f b -> ExceptT e f a Source #
Functor f => Functor (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods fmap :: (a -> b) -> ExceptT e f a -> ExceptT e f b Source # (<$) :: a -> ExceptT e f b -> ExceptT e f a Source #
(Selective f, Monad f) => Monad (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods (>>=) :: ExceptT e f a -> (a -> ExceptT e f b) -> ExceptT e f b Source # (>>) :: ExceptT e f a -> ExceptT e f b -> ExceptT e f b Source # return :: a -> ExceptT e f a Source #
(Selective f, Monoid e, Monad f) => MonadPlus (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods mzero :: ExceptT e f a Source # mplus :: ExceptT e f a -> ExceptT e f a -> ExceptT e f a Source #
(Selective f, MonadFail f) => MonadFail (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods fail :: String -> ExceptT e f a Source #
(Selective f, MonadFix f) => MonadFix (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods mfix :: (a -> ExceptT e f a) -> ExceptT e f a Source #
Foldable f => Foldable (ExceptT e f) Source # |

Instance details

Defined in Control.Selective.Trans.Except

Methods

fold :: Monoid m => ExceptT e f m -> m Source #

foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ExceptT e f a -> m Source #

foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b Source #

foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b Source #

foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b Source #

foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b Source #

foldr1 :: (a -> a -> a) -> ExceptT e f a -> a Source #

foldl1 :: (a -> a -> a) -> ExceptT e f a -> a Source #

toList :: ExceptT e f a -> [a] Source #

null :: ExceptT e f a -> Bool Source #

length :: ExceptT e f a -> Int Source #

elem :: Eq a => a -> ExceptT e f a -> Bool Source #

maximum :: Ord a => ExceptT e f a -> a Source #

minimum :: Ord a => ExceptT e f a -> a Source #

sum :: Num a => ExceptT e f a -> a Source #

product :: Num a => ExceptT e f a -> a Source #

Traversable f => Traversable (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods traverse :: Applicative f0 => (a -> f0 b) -> ExceptT e f a -> f0 (ExceptT e f b) Source # sequenceA :: Applicative f0 => ExceptT e f (f0 a) -> f0 (ExceptT e f a) Source # mapM :: Monad m => (a -> m b) -> ExceptT e f a -> m (ExceptT e f b) Source # sequence :: Monad m => ExceptT e f (m a) -> m (ExceptT e f a) Source #
Selective f => Selective (ExceptT e f) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods select :: ExceptT e f (Either a b) -> ExceptT e f (a -> b) -> ExceptT e f b Source #
(Read1 f, Read e, Read a) => Read (ExceptT e f a) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods readsPrec :: Int -> ReadS (ExceptT e f a) Source # readList :: ReadS [ExceptT e f a] Source # readPrec :: ReadPrec (ExceptT e f a) Source # readListPrec :: ReadPrec [ExceptT e f a] Source #
(Show1 f, Show e, Show a) => Show (ExceptT e f a) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods showsPrec :: Int -> ExceptT e f a -> ShowS Source # show :: ExceptT e f a -> String Source # showList :: [ExceptT e f a] -> ShowS Source #
(Eq1 f, Eq e, Eq a) => Eq (ExceptT e f a) Source # |
Instance details Defined in Control.Selective.Trans.Except Methods (==) :: ExceptT e f a -> ExceptT e f a -> Bool Source # (/=) :: ExceptT e f a -> ExceptT e f a -> Bool Source #
(Ord1 f, Ord e, Ord a) => Ord (ExceptT e f a) Source # |

Instance details

Defined in Control.Selective.Trans.Except

Methods

compare :: ExceptT e f a -> ExceptT e f a -> Ordering Source #

(<) :: ExceptT e f a -> ExceptT e f a -> Bool Source #

(<=) :: ExceptT e f a -> ExceptT e f a -> Bool Source #

(>) :: ExceptT e f a -> ExceptT e f a -> Bool Source #

(>=) :: ExceptT e f a -> ExceptT e f a -> Bool Source #

max :: ExceptT e f a -> ExceptT e f a -> ExceptT e f a Source #

min :: ExceptT e f a -> ExceptT e f a -> ExceptT e f a Source #

wrap :: forall e (m :: Type -> Type) a. ExceptT e m a -> ExceptT e m a Source #

Inject an `ExceptT` value into the newtype wrapper.

type Except e = ExceptT e Identity Source #

except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a Source #

runExcept :: Except e a -> Either e a Source #

mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b Source #

withExcept :: (e -> e') -> Except e a -> Except e' a Source #

runExceptT :: ExceptT e m a -> m (Either e a) Source #

mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b Source #

withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a Source #

throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a Source #

catchE :: forall (m :: Type -> Type) e a e'. Monad m => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a Source #

liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b Source #

liftListen :: Monad m => Listen w m (Either e a) -> Listen w (ExceptT e m) a Source #

liftPass :: Monad m => Pass w m (Either e a) -> Pass w (ExceptT e m) a Source #