constrained-monads-0.1.0.0: Typeclasses and instances for monads with constraints.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Constrained

Contents

Description

A module for constrained monads. This module is intended to be imported with the -XRebindableSyntax extension turned on: everything from the Prelude (that doesn't conflict with the new Functor, Applicative, etc) is reexported, so these type classes can be used the same way that the Prelude classes are used.

Synopsis

Basic Classes

class Functor f where Source #

This is the same class as Functor from the Prelude. Most of the functions here are simply rewritten versions of those, with one difference: types can indicate which types they can contain. This allows Set to be made into a monad, as well as some other exotic types. (but, to be fair, Set is kind of the poster child for this technique).

The way that types indicate what they can contain is with the Suitable associated type.

The default implementation is for types which conform to the Prelude's Functor. The way to make a standard Functor conform is by indicating that it has no constraints. For instance, for []:

instance Functor [] where
  type Suitable [] a = ()
  fmap = map
  (<$) = (Prelude.<$)

Monomorphic types can also conform, using GADT aliases. For instance, if you create an alias for IntSet of kind * -> *:

data IntSet a where
  IntSet :: IntSet.IntSet -> IntSet Int

It can be made to conform to Functor like so:

instance Functor IntSet where
  type Suitable IntSet a = a ~ Int
  fmap f (IntSet xs) = IntSet (IntSet.map f xs)
  x <$ xs = if null xs then empty else pure x

It can also be made conform to Foldable, etc. This type is provided in Control.Monad.Constrained.IntSet.

Minimal complete definition

fmap

Associated Types

type Suitable f a :: Constraint Source #

Indicate which types can be contained by f. For instance, Set conforms like so:

instance Functor Set where
    type Suitable Set a = Ord a
    fmap = map

Methods

fmap :: Suitable f b => (a -> b) -> f a -> f b Source #

Maps a function over a functor

(<$) :: Suitable f a => a -> f b -> f a infixl 4 Source #

Replace all values in the input with a default value.

Instances

Functor [] Source # 

Associated Types

type Suitable ([] :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable [] b => (a -> b) -> [a] -> [b] Source #

(<$) :: Suitable [] a => a -> [b] -> [a] Source #

Functor Maybe Source # 

Associated Types

type Suitable (Maybe :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable Maybe b => (a -> b) -> Maybe a -> Maybe b Source #

(<$) :: Suitable Maybe a => a -> Maybe b -> Maybe a Source #

Functor IO Source # 

Associated Types

type Suitable (IO :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable IO b => (a -> b) -> IO a -> IO b Source #

(<$) :: Suitable IO a => a -> IO b -> IO a Source #

Functor Identity Source # 

Associated Types

type Suitable (Identity :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable Identity b => (a -> b) -> Identity a -> Identity b Source #

(<$) :: Suitable Identity a => a -> Identity b -> Identity a Source #

Functor ZipList Source # 

Associated Types

type Suitable (ZipList :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable ZipList b => (a -> b) -> ZipList a -> ZipList b Source #

(<$) :: Suitable ZipList a => a -> ZipList b -> ZipList a Source #

Functor IntMap Source # 

Associated Types

type Suitable (IntMap :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable IntMap b => (a -> b) -> IntMap a -> IntMap b Source #

(<$) :: Suitable IntMap a => a -> IntMap b -> IntMap a Source #

Functor Tree Source # 

Associated Types

type Suitable (Tree :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable Tree b => (a -> b) -> Tree a -> Tree b Source #

(<$) :: Suitable Tree a => a -> Tree b -> Tree a Source #

Functor Seq Source # 

Associated Types

type Suitable (Seq :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable Seq b => (a -> b) -> Seq a -> Seq b Source #

(<$) :: Suitable Seq a => a -> Seq b -> Seq a Source #

Functor Set Source # 

Associated Types

type Suitable (Set :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable Set b => (a -> b) -> Set a -> Set b Source #

(<$) :: Suitable Set a => a -> Set b -> Set a Source #

Functor IntSet Source # 

Associated Types

type Suitable (IntSet :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable IntSet b => (a -> b) -> IntSet a -> IntSet b Source #

(<$) :: Suitable IntSet a => a -> IntSet b -> IntSet a Source #

Functor ((->) a) Source # 

Associated Types

type Suitable ((->) a :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable ((->) a) b => (a -> b) -> (a -> a) -> a -> b Source #

(<$) :: Suitable ((->) a) a => a -> (a -> b) -> a -> a Source #

Functor (Either e) Source # 

Associated Types

type Suitable (Either e :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (Either e) b => (a -> b) -> Either e a -> Either e b Source #

(<$) :: Suitable (Either e) a => a -> Either e b -> Either e a Source #

Functor ((,) a) Source # 

Associated Types

type Suitable ((,) a :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable ((,) a) b => (a -> b) -> (a, a) -> (a, b) Source #

(<$) :: Suitable ((,) a) a => a -> (a, b) -> (a, a) Source #

Functor (Map a) Source # 

Associated Types

type Suitable (Map a :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (Map a) b => (a -> b) -> Map a a -> Map a b Source #

(<$) :: Suitable (Map a) a => a -> Map a b -> Map a a Source #

Functor m => Functor (MaybeT m) Source # 

Associated Types

type Suitable (MaybeT m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (MaybeT m) b => (a -> b) -> MaybeT m a -> MaybeT m b Source #

(<$) :: Suitable (MaybeT m) a => a -> MaybeT m b -> MaybeT m a Source #

Functor m => Functor (StateT s m) Source # 

Associated Types

type Suitable (StateT s m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (StateT s m) b => (a -> b) -> StateT s m a -> StateT s m b Source #

(<$) :: Suitable (StateT s m) a => a -> StateT s m b -> StateT s m a Source #

Functor m => Functor (StateT s m) Source # 

Associated Types

type Suitable (StateT s m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (StateT s m) b => (a -> b) -> StateT s m a -> StateT s m b Source #

(<$) :: Suitable (StateT s m) a => a -> StateT s m b -> StateT s m a Source #

Functor m => Functor (IdentityT * m) Source # 

Associated Types

type Suitable (IdentityT * m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (IdentityT * m) b => (a -> b) -> IdentityT * m a -> IdentityT * m b Source #

(<$) :: Suitable (IdentityT * m) a => a -> IdentityT * m b -> IdentityT * m a Source #

Functor m => Functor (ExceptT e m) Source # 

Associated Types

type Suitable (ExceptT e m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (ExceptT e m) b => (a -> b) -> ExceptT e m a -> ExceptT e m b Source #

(<$) :: Suitable (ExceptT e m) a => a -> ExceptT e m b -> ExceptT e m a Source #

Functor m => Functor (WriterT s m) Source # 

Associated Types

type Suitable (WriterT s m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (WriterT s m) b => (a -> b) -> WriterT s m a -> WriterT s m b Source #

(<$) :: Suitable (WriterT s m) a => a -> WriterT s m b -> WriterT s m a Source #

Functor m => Functor (ReaderT * r m) Source # 

Associated Types

type Suitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (ReaderT * r m) b => (a -> b) -> ReaderT * r m a -> ReaderT * r m b Source #

(<$) :: Suitable (ReaderT * r m) a => a -> ReaderT * r m b -> ReaderT * r m a Source #

Functor (ContT * r m) Source # 

Associated Types

type Suitable (ContT * r m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (ContT * r m) b => (a -> b) -> ContT * r m a -> ContT * r m b Source #

(<$) :: Suitable (ContT * r m) a => a -> ContT * r m b -> ContT * r m a Source #

class Functor f => Applicative f where Source #

A functor with application.

This class is slightly different (although equivalent) to the class provided in the Prelude. This is to facilitate the lifting of functions to arbitrary numbers of arguments.

A minimal complete definition must include implementations of liftA functions satisfying the following laws:

identity
pure id <*> v = v
composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
homomorphism
pure f <*> pure x = pure (f x)
interchange
u <*> pure y = pure ($ y) <*> u

The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:

As a consequence of these laws, the Functor instance for f will satisfy

If f is also a Monad, it should satisfy

(which implies that pure and <*> satisfy the applicative functor laws).

Minimal complete definition

liftA

Methods

pure :: Suitable f a => a -> f a Source #

Lift a value.

(<*>) :: Suitable f b => f (a -> b) -> f a -> f b infixl 4 Source #

Sequential application.

(*>) :: Suitable f b => f a -> f b -> f b infixl 4 Source #

Sequence actions, discarding the value of the first argument.

(<*) :: Suitable f a => f a -> f b -> f a infixl 4 Source #

Sequence actions, discarding the value of the second argument.

liftA :: Suitable f b => (Vect xs -> b) -> AppVect f xs -> f b Source #

The shenanigans introduced by this function are to account for the fact that you can't (I don't think) write an arbitrary lift function on non-monadic applicatives that have constrained types. For instance, if the only present functions are:

pure  :: Suitable f a => a -> f b
fmap  :: Suitable f b => (a -> b) -> f a -> f b
(<*>) :: Suitable f b => f (a -> b) -> f a -> f b

I can't see a way to define:

liftA2 :: Suitable f c => (a -> b -> c) -> f a -> f b -> f c

Of course, if:

(>>=) :: Suitable f b => f a -> (a -> f b) -> f b

is available, liftA2 could be defined as:

liftA2 f xs ys = do
    x <- xs
    y <- ys
    pure (f x)

But now we can't define the liftA functions for things which are Applicative but not Monad (square matrices, ZipLists, etc). Also, some types have a more efficient (<*>) than (>>=) (see, for instance, the Haxl monad).

The one missing piece is -XApplicativeDo: I can't figure out a way to get do-notation to desugar to using the liftA functions, rather than (<*>).

It would also be preferable to avoid the two intermediate structures (Vect, AppVect, etc). Ideally GHC would optimize them away, but it seems unlikely.

Utility definitions of this function are provided: if your Applicative is a Prelude.Applicative, liftA can be defined in terms of (<*>). liftAP does exactly this.

Alternatively, if your applicative is a Monad, liftA can be defined in terms of (>>=), which is what liftAM does.

liftA2 :: Suitable f c => (a -> b -> c) -> f a -> f b -> f c Source #

liftA3 :: Suitable f d => (a -> b -> c -> d) -> f a -> f b -> f c -> f d Source #

liftA4 :: Suitable f e => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e Source #

liftA5 :: Suitable f g => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g Source #

liftA6 :: Suitable f h => (a -> b -> c -> d -> e -> g -> h) -> f a -> f b -> f c -> f d -> f e -> f g -> f h Source #

liftA7 :: Suitable f i => (a -> b -> c -> d -> e -> g -> h -> i) -> f a -> f b -> f c -> f d -> f e -> f g -> f h -> f i Source #

liftA8 :: Suitable f j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> f a -> f b -> f c -> f d -> f e -> f g -> f h -> f i -> f j Source #

liftA9 :: Suitable f k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> f a -> f b -> f c -> f d -> f e -> f g -> f h -> f i -> f j -> f k Source #

Instances

Applicative [] Source # 

Methods

pure :: Suitable [] a => a -> [a] Source #

(<*>) :: Suitable [] b => [a -> b] -> [a] -> [b] Source #

(*>) :: Suitable [] b => [a] -> [b] -> [b] Source #

(<*) :: Suitable [] a => [a] -> [b] -> [a] Source #

liftA :: Suitable [] b => (Vect xs -> b) -> AppVect [] xs -> [b] Source #

liftA2 :: Suitable [] c => (a -> b -> c) -> [a] -> [b] -> [c] Source #

liftA3 :: Suitable [] d => (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] Source #

liftA4 :: Suitable [] e => (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e] Source #

liftA5 :: Suitable [] g => (a -> b -> c -> d -> e -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [g] Source #

liftA6 :: Suitable [] h => (a -> b -> c -> d -> e -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [g] -> [h] Source #

liftA7 :: Suitable [] i => (a -> b -> c -> d -> e -> g -> h -> i) -> [a] -> [b] -> [c] -> [d] -> [e] -> [g] -> [h] -> [i] Source #

liftA8 :: Suitable [] j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> [a] -> [b] -> [c] -> [d] -> [e] -> [g] -> [h] -> [i] -> [j] Source #

liftA9 :: Suitable [] k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> [a] -> [b] -> [c] -> [d] -> [e] -> [g] -> [h] -> [i] -> [j] -> [k] Source #

Applicative Maybe Source # 

Methods

pure :: Suitable Maybe a => a -> Maybe a Source #

(<*>) :: Suitable Maybe b => Maybe (a -> b) -> Maybe a -> Maybe b Source #

(*>) :: Suitable Maybe b => Maybe a -> Maybe b -> Maybe b Source #

(<*) :: Suitable Maybe a => Maybe a -> Maybe b -> Maybe a Source #

liftA :: Suitable Maybe b => (Vect xs -> b) -> AppVect Maybe xs -> Maybe b Source #

liftA2 :: Suitable Maybe c => (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #

liftA3 :: Suitable Maybe d => (a -> b -> c -> d) -> Maybe a -> Maybe b -> Maybe c -> Maybe d Source #

liftA4 :: Suitable Maybe e => (a -> b -> c -> d -> e) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e Source #

liftA5 :: Suitable Maybe g => (a -> b -> c -> d -> e -> g) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe g Source #

liftA6 :: Suitable Maybe h => (a -> b -> c -> d -> e -> g -> h) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe g -> Maybe h Source #

liftA7 :: Suitable Maybe i => (a -> b -> c -> d -> e -> g -> h -> i) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe g -> Maybe h -> Maybe i Source #

liftA8 :: Suitable Maybe j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe g -> Maybe h -> Maybe i -> Maybe j Source #

liftA9 :: Suitable Maybe k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Maybe a -> Maybe b -> Maybe c -> Maybe d -> Maybe e -> Maybe g -> Maybe h -> Maybe i -> Maybe j -> Maybe k Source #

Applicative IO Source # 

Methods

pure :: Suitable IO a => a -> IO a Source #

(<*>) :: Suitable IO b => IO (a -> b) -> IO a -> IO b Source #

(*>) :: Suitable IO b => IO a -> IO b -> IO b Source #

(<*) :: Suitable IO a => IO a -> IO b -> IO a Source #

liftA :: Suitable IO b => (Vect xs -> b) -> AppVect IO xs -> IO b Source #

liftA2 :: Suitable IO c => (a -> b -> c) -> IO a -> IO b -> IO c Source #

liftA3 :: Suitable IO d => (a -> b -> c -> d) -> IO a -> IO b -> IO c -> IO d Source #

liftA4 :: Suitable IO e => (a -> b -> c -> d -> e) -> IO a -> IO b -> IO c -> IO d -> IO e Source #

liftA5 :: Suitable IO g => (a -> b -> c -> d -> e -> g) -> IO a -> IO b -> IO c -> IO d -> IO e -> IO g Source #

liftA6 :: Suitable IO h => (a -> b -> c -> d -> e -> g -> h) -> IO a -> IO b -> IO c -> IO d -> IO e -> IO g -> IO h Source #

liftA7 :: Suitable IO i => (a -> b -> c -> d -> e -> g -> h -> i) -> IO a -> IO b -> IO c -> IO d -> IO e -> IO g -> IO h -> IO i Source #

liftA8 :: Suitable IO j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> IO a -> IO b -> IO c -> IO d -> IO e -> IO g -> IO h -> IO i -> IO j Source #

liftA9 :: Suitable IO k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> IO a -> IO b -> IO c -> IO d -> IO e -> IO g -> IO h -> IO i -> IO j -> IO k Source #

Applicative Identity Source # 

Methods

pure :: Suitable Identity a => a -> Identity a Source #

(<*>) :: Suitable Identity b => Identity (a -> b) -> Identity a -> Identity b Source #

(*>) :: Suitable Identity b => Identity a -> Identity b -> Identity b Source #

(<*) :: Suitable Identity a => Identity a -> Identity b -> Identity a Source #

liftA :: Suitable Identity b => (Vect xs -> b) -> AppVect Identity xs -> Identity b Source #

liftA2 :: Suitable Identity c => (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #

liftA3 :: Suitable Identity d => (a -> b -> c -> d) -> Identity a -> Identity b -> Identity c -> Identity d Source #

liftA4 :: Suitable Identity e => (a -> b -> c -> d -> e) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e Source #

liftA5 :: Suitable Identity g => (a -> b -> c -> d -> e -> g) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e -> Identity g Source #

liftA6 :: Suitable Identity h => (a -> b -> c -> d -> e -> g -> h) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e -> Identity g -> Identity h Source #

liftA7 :: Suitable Identity i => (a -> b -> c -> d -> e -> g -> h -> i) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e -> Identity g -> Identity h -> Identity i Source #

liftA8 :: Suitable Identity j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e -> Identity g -> Identity h -> Identity i -> Identity j Source #

liftA9 :: Suitable Identity k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Identity a -> Identity b -> Identity c -> Identity d -> Identity e -> Identity g -> Identity h -> Identity i -> Identity j -> Identity k Source #

Applicative ZipList Source # 

Methods

pure :: Suitable ZipList a => a -> ZipList a Source #

(<*>) :: Suitable ZipList b => ZipList (a -> b) -> ZipList a -> ZipList b Source #

(*>) :: Suitable ZipList b => ZipList a -> ZipList b -> ZipList b Source #

(<*) :: Suitable ZipList a => ZipList a -> ZipList b -> ZipList a Source #

liftA :: Suitable ZipList b => (Vect xs -> b) -> AppVect ZipList xs -> ZipList b Source #

liftA2 :: Suitable ZipList c => (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #

liftA3 :: Suitable ZipList d => (a -> b -> c -> d) -> ZipList a -> ZipList b -> ZipList c -> ZipList d Source #

liftA4 :: Suitable ZipList e => (a -> b -> c -> d -> e) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e Source #

liftA5 :: Suitable ZipList g => (a -> b -> c -> d -> e -> g) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e -> ZipList g Source #

liftA6 :: Suitable ZipList h => (a -> b -> c -> d -> e -> g -> h) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e -> ZipList g -> ZipList h Source #

liftA7 :: Suitable ZipList i => (a -> b -> c -> d -> e -> g -> h -> i) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e -> ZipList g -> ZipList h -> ZipList i Source #

liftA8 :: Suitable ZipList j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e -> ZipList g -> ZipList h -> ZipList i -> ZipList j Source #

liftA9 :: Suitable ZipList k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> ZipList a -> ZipList b -> ZipList c -> ZipList d -> ZipList e -> ZipList g -> ZipList h -> ZipList i -> ZipList j -> ZipList k Source #

Applicative Tree Source # 

Methods

pure :: Suitable Tree a => a -> Tree a Source #

(<*>) :: Suitable Tree b => Tree (a -> b) -> Tree a -> Tree b Source #

(*>) :: Suitable Tree b => Tree a -> Tree b -> Tree b Source #

(<*) :: Suitable Tree a => Tree a -> Tree b -> Tree a Source #

liftA :: Suitable Tree b => (Vect xs -> b) -> AppVect Tree xs -> Tree b Source #

liftA2 :: Suitable Tree c => (a -> b -> c) -> Tree a -> Tree b -> Tree c Source #

liftA3 :: Suitable Tree d => (a -> b -> c -> d) -> Tree a -> Tree b -> Tree c -> Tree d Source #

liftA4 :: Suitable Tree e => (a -> b -> c -> d -> e) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e Source #

liftA5 :: Suitable Tree g => (a -> b -> c -> d -> e -> g) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e -> Tree g Source #

liftA6 :: Suitable Tree h => (a -> b -> c -> d -> e -> g -> h) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e -> Tree g -> Tree h Source #

liftA7 :: Suitable Tree i => (a -> b -> c -> d -> e -> g -> h -> i) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e -> Tree g -> Tree h -> Tree i Source #

liftA8 :: Suitable Tree j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e -> Tree g -> Tree h -> Tree i -> Tree j Source #

liftA9 :: Suitable Tree k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Tree a -> Tree b -> Tree c -> Tree d -> Tree e -> Tree g -> Tree h -> Tree i -> Tree j -> Tree k Source #

Applicative Seq Source # 

Methods

pure :: Suitable Seq a => a -> Seq a Source #

(<*>) :: Suitable Seq b => Seq (a -> b) -> Seq a -> Seq b Source #

(*>) :: Suitable Seq b => Seq a -> Seq b -> Seq b Source #

(<*) :: Suitable Seq a => Seq a -> Seq b -> Seq a Source #

liftA :: Suitable Seq b => (Vect xs -> b) -> AppVect Seq xs -> Seq b Source #

liftA2 :: Suitable Seq c => (a -> b -> c) -> Seq a -> Seq b -> Seq c Source #

liftA3 :: Suitable Seq d => (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d Source #

liftA4 :: Suitable Seq e => (a -> b -> c -> d -> e) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e Source #

liftA5 :: Suitable Seq g => (a -> b -> c -> d -> e -> g) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e -> Seq g Source #

liftA6 :: Suitable Seq h => (a -> b -> c -> d -> e -> g -> h) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e -> Seq g -> Seq h Source #

liftA7 :: Suitable Seq i => (a -> b -> c -> d -> e -> g -> h -> i) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e -> Seq g -> Seq h -> Seq i Source #

liftA8 :: Suitable Seq j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e -> Seq g -> Seq h -> Seq i -> Seq j Source #

liftA9 :: Suitable Seq k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e -> Seq g -> Seq h -> Seq i -> Seq j -> Seq k Source #

Applicative Set Source # 

Methods

pure :: Suitable Set a => a -> Set a Source #

(<*>) :: Suitable Set b => Set (a -> b) -> Set a -> Set b Source #

(*>) :: Suitable Set b => Set a -> Set b -> Set b Source #

(<*) :: Suitable Set a => Set a -> Set b -> Set a Source #

liftA :: Suitable Set b => (Vect xs -> b) -> AppVect Set xs -> Set b Source #

liftA2 :: Suitable Set c => (a -> b -> c) -> Set a -> Set b -> Set c Source #

liftA3 :: Suitable Set d => (a -> b -> c -> d) -> Set a -> Set b -> Set c -> Set d Source #

liftA4 :: Suitable Set e => (a -> b -> c -> d -> e) -> Set a -> Set b -> Set c -> Set d -> Set e Source #

liftA5 :: Suitable Set g => (a -> b -> c -> d -> e -> g) -> Set a -> Set b -> Set c -> Set d -> Set e -> Set g Source #

liftA6 :: Suitable Set h => (a -> b -> c -> d -> e -> g -> h) -> Set a -> Set b -> Set c -> Set d -> Set e -> Set g -> Set h Source #

liftA7 :: Suitable Set i => (a -> b -> c -> d -> e -> g -> h -> i) -> Set a -> Set b -> Set c -> Set d -> Set e -> Set g -> Set h -> Set i Source #

liftA8 :: Suitable Set j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Set a -> Set b -> Set c -> Set d -> Set e -> Set g -> Set h -> Set i -> Set j Source #

liftA9 :: Suitable Set k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Set a -> Set b -> Set c -> Set d -> Set e -> Set g -> Set h -> Set i -> Set j -> Set k Source #

Applicative IntSet Source # 

Methods

pure :: Suitable IntSet a => a -> IntSet a Source #

(<*>) :: Suitable IntSet b => IntSet (a -> b) -> IntSet a -> IntSet b Source #

(*>) :: Suitable IntSet b => IntSet a -> IntSet b -> IntSet b Source #

(<*) :: Suitable IntSet a => IntSet a -> IntSet b -> IntSet a Source #

liftA :: Suitable IntSet b => (Vect xs -> b) -> AppVect IntSet xs -> IntSet b Source #

liftA2 :: Suitable IntSet c => (a -> b -> c) -> IntSet a -> IntSet b -> IntSet c Source #

liftA3 :: Suitable IntSet d => (a -> b -> c -> d) -> IntSet a -> IntSet b -> IntSet c -> IntSet d Source #

liftA4 :: Suitable IntSet e => (a -> b -> c -> d -> e) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e Source #

liftA5 :: Suitable IntSet g => (a -> b -> c -> d -> e -> g) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e -> IntSet g Source #

liftA6 :: Suitable IntSet h => (a -> b -> c -> d -> e -> g -> h) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e -> IntSet g -> IntSet h Source #

liftA7 :: Suitable IntSet i => (a -> b -> c -> d -> e -> g -> h -> i) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e -> IntSet g -> IntSet h -> IntSet i Source #

liftA8 :: Suitable IntSet j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e -> IntSet g -> IntSet h -> IntSet i -> IntSet j Source #

liftA9 :: Suitable IntSet k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> IntSet a -> IntSet b -> IntSet c -> IntSet d -> IntSet e -> IntSet g -> IntSet h -> IntSet i -> IntSet j -> IntSet k Source #

Applicative ((->) a) Source # 

Methods

pure :: Suitable ((->) a) a => a -> a -> a Source #

(<*>) :: Suitable ((->) a) b => (a -> a -> b) -> (a -> a) -> a -> b Source #

(*>) :: Suitable ((->) a) b => (a -> a) -> (a -> b) -> a -> b Source #

(<*) :: Suitable ((->) a) a => (a -> a) -> (a -> b) -> a -> a Source #

liftA :: Suitable ((->) a) b => (Vect xs -> b) -> AppVect ((->) a) xs -> a -> b Source #

liftA2 :: Suitable ((->) a) c => (a -> b -> c) -> (a -> a) -> (a -> b) -> a -> c Source #

liftA3 :: Suitable ((->) a) d => (a -> b -> c -> d) -> (a -> a) -> (a -> b) -> (a -> c) -> a -> d Source #

liftA4 :: Suitable ((->) a) e => (a -> b -> c -> d -> e) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> a -> e Source #

liftA5 :: Suitable ((->) a) g => (a -> b -> c -> d -> e -> g) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> (a -> e) -> a -> g Source #

liftA6 :: Suitable ((->) a) h => (a -> b -> c -> d -> e -> g -> h) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> (a -> e) -> (a -> g) -> a -> h Source #

liftA7 :: Suitable ((->) a) i => (a -> b -> c -> d -> e -> g -> h -> i) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> (a -> e) -> (a -> g) -> (a -> h) -> a -> i Source #

liftA8 :: Suitable ((->) a) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> (a -> e) -> (a -> g) -> (a -> h) -> (a -> i) -> a -> j Source #

liftA9 :: Suitable ((->) a) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> (a -> a) -> (a -> b) -> (a -> c) -> (a -> d) -> (a -> e) -> (a -> g) -> (a -> h) -> (a -> i) -> (a -> j) -> a -> k Source #

Applicative (Either a) Source # 

Methods

pure :: Suitable (Either a) a => a -> Either a a Source #

(<*>) :: Suitable (Either a) b => Either a (a -> b) -> Either a a -> Either a b Source #

(*>) :: Suitable (Either a) b => Either a a -> Either a b -> Either a b Source #

(<*) :: Suitable (Either a) a => Either a a -> Either a b -> Either a a Source #

liftA :: Suitable (Either a) b => (Vect xs -> b) -> AppVect (Either a) xs -> Either a b Source #

liftA2 :: Suitable (Either a) c => (a -> b -> c) -> Either a a -> Either a b -> Either a c Source #

liftA3 :: Suitable (Either a) d => (a -> b -> c -> d) -> Either a a -> Either a b -> Either a c -> Either a d Source #

liftA4 :: Suitable (Either a) e => (a -> b -> c -> d -> e) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e Source #

liftA5 :: Suitable (Either a) g => (a -> b -> c -> d -> e -> g) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e -> Either a g Source #

liftA6 :: Suitable (Either a) h => (a -> b -> c -> d -> e -> g -> h) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e -> Either a g -> Either a h Source #

liftA7 :: Suitable (Either a) i => (a -> b -> c -> d -> e -> g -> h -> i) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e -> Either a g -> Either a h -> Either a i Source #

liftA8 :: Suitable (Either a) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e -> Either a g -> Either a h -> Either a i -> Either a j Source #

liftA9 :: Suitable (Either a) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> Either a a -> Either a b -> Either a c -> Either a d -> Either a e -> Either a g -> Either a h -> Either a i -> Either a j -> Either a k Source #

Monoid a => Applicative ((,) a) Source # 

Methods

pure :: Suitable ((,) a) a => a -> (a, a) Source #

(<*>) :: Suitable ((,) a) b => (a, a -> b) -> (a, a) -> (a, b) Source #

(*>) :: Suitable ((,) a) b => (a, a) -> (a, b) -> (a, b) Source #

(<*) :: Suitable ((,) a) a => (a, a) -> (a, b) -> (a, a) Source #

liftA :: Suitable ((,) a) b => (Vect xs -> b) -> AppVect ((,) a) xs -> (a, b) Source #

liftA2 :: Suitable ((,) a) c => (a -> b -> c) -> (a, a) -> (a, b) -> (a, c) Source #

liftA3 :: Suitable ((,) a) d => (a -> b -> c -> d) -> (a, a) -> (a, b) -> (a, c) -> (a, d) Source #

liftA4 :: Suitable ((,) a) e => (a -> b -> c -> d -> e) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) Source #

liftA5 :: Suitable ((,) a) g => (a -> b -> c -> d -> e -> g) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) -> (a, g) Source #

liftA6 :: Suitable ((,) a) h => (a -> b -> c -> d -> e -> g -> h) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) -> (a, g) -> (a, h) Source #

liftA7 :: Suitable ((,) a) i => (a -> b -> c -> d -> e -> g -> h -> i) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) -> (a, g) -> (a, h) -> (a, i) Source #

liftA8 :: Suitable ((,) a) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) -> (a, g) -> (a, h) -> (a, i) -> (a, j) Source #

liftA9 :: Suitable ((,) a) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> (a, a) -> (a, b) -> (a, c) -> (a, d) -> (a, e) -> (a, g) -> (a, h) -> (a, i) -> (a, j) -> (a, k) Source #

Monad m => Applicative (MaybeT m) Source # 

Methods

pure :: Suitable (MaybeT m) a => a -> MaybeT m a Source #

(<*>) :: Suitable (MaybeT m) b => MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b Source #

(*>) :: Suitable (MaybeT m) b => MaybeT m a -> MaybeT m b -> MaybeT m b Source #

(<*) :: Suitable (MaybeT m) a => MaybeT m a -> MaybeT m b -> MaybeT m a Source #

liftA :: Suitable (MaybeT m) b => (Vect xs -> b) -> AppVect (MaybeT m) xs -> MaybeT m b Source #

liftA2 :: Suitable (MaybeT m) c => (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c Source #

liftA3 :: Suitable (MaybeT m) d => (a -> b -> c -> d) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d Source #

liftA4 :: Suitable (MaybeT m) e => (a -> b -> c -> d -> e) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e Source #

liftA5 :: Suitable (MaybeT m) g => (a -> b -> c -> d -> e -> g) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e -> MaybeT m g Source #

liftA6 :: Suitable (MaybeT m) h => (a -> b -> c -> d -> e -> g -> h) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e -> MaybeT m g -> MaybeT m h Source #

liftA7 :: Suitable (MaybeT m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e -> MaybeT m g -> MaybeT m h -> MaybeT m i Source #

liftA8 :: Suitable (MaybeT m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e -> MaybeT m g -> MaybeT m h -> MaybeT m i -> MaybeT m j Source #

liftA9 :: Suitable (MaybeT m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> MaybeT m a -> MaybeT m b -> MaybeT m c -> MaybeT m d -> MaybeT m e -> MaybeT m g -> MaybeT m h -> MaybeT m i -> MaybeT m j -> MaybeT m k Source #

Monad m => Applicative (StateT s m) Source # 

Methods

pure :: Suitable (StateT s m) a => a -> StateT s m a Source #

(<*>) :: Suitable (StateT s m) b => StateT s m (a -> b) -> StateT s m a -> StateT s m b Source #

(*>) :: Suitable (StateT s m) b => StateT s m a -> StateT s m b -> StateT s m b Source #

(<*) :: Suitable (StateT s m) a => StateT s m a -> StateT s m b -> StateT s m a Source #

liftA :: Suitable (StateT s m) b => (Vect xs -> b) -> AppVect (StateT s m) xs -> StateT s m b Source #

liftA2 :: Suitable (StateT s m) c => (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #

liftA3 :: Suitable (StateT s m) d => (a -> b -> c -> d) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d Source #

liftA4 :: Suitable (StateT s m) e => (a -> b -> c -> d -> e) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e Source #

liftA5 :: Suitable (StateT s m) g => (a -> b -> c -> d -> e -> g) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g Source #

liftA6 :: Suitable (StateT s m) h => (a -> b -> c -> d -> e -> g -> h) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h Source #

liftA7 :: Suitable (StateT s m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i Source #

liftA8 :: Suitable (StateT s m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i -> StateT s m j Source #

liftA9 :: Suitable (StateT s m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i -> StateT s m j -> StateT s m k Source #

Monad m => Applicative (StateT s m) Source # 

Methods

pure :: Suitable (StateT s m) a => a -> StateT s m a Source #

(<*>) :: Suitable (StateT s m) b => StateT s m (a -> b) -> StateT s m a -> StateT s m b Source #

(*>) :: Suitable (StateT s m) b => StateT s m a -> StateT s m b -> StateT s m b Source #

(<*) :: Suitable (StateT s m) a => StateT s m a -> StateT s m b -> StateT s m a Source #

liftA :: Suitable (StateT s m) b => (Vect xs -> b) -> AppVect (StateT s m) xs -> StateT s m b Source #

liftA2 :: Suitable (StateT s m) c => (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #

liftA3 :: Suitable (StateT s m) d => (a -> b -> c -> d) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d Source #

liftA4 :: Suitable (StateT s m) e => (a -> b -> c -> d -> e) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e Source #

liftA5 :: Suitable (StateT s m) g => (a -> b -> c -> d -> e -> g) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g Source #

liftA6 :: Suitable (StateT s m) h => (a -> b -> c -> d -> e -> g -> h) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h Source #

liftA7 :: Suitable (StateT s m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i Source #

liftA8 :: Suitable (StateT s m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i -> StateT s m j Source #

liftA9 :: Suitable (StateT s m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> StateT s m a -> StateT s m b -> StateT s m c -> StateT s m d -> StateT s m e -> StateT s m g -> StateT s m h -> StateT s m i -> StateT s m j -> StateT s m k Source #

Applicative m => Applicative (IdentityT * m) Source # 

Methods

pure :: Suitable (IdentityT * m) a => a -> IdentityT * m a Source #

(<*>) :: Suitable (IdentityT * m) b => IdentityT * m (a -> b) -> IdentityT * m a -> IdentityT * m b Source #

(*>) :: Suitable (IdentityT * m) b => IdentityT * m a -> IdentityT * m b -> IdentityT * m b Source #

(<*) :: Suitable (IdentityT * m) a => IdentityT * m a -> IdentityT * m b -> IdentityT * m a Source #

liftA :: Suitable (IdentityT * m) b => (Vect xs -> b) -> AppVect (IdentityT * m) xs -> IdentityT * m b Source #

liftA2 :: Suitable (IdentityT * m) c => (a -> b -> c) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c Source #

liftA3 :: Suitable (IdentityT * m) d => (a -> b -> c -> d) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d Source #

liftA4 :: Suitable (IdentityT * m) e => (a -> b -> c -> d -> e) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e Source #

liftA5 :: Suitable (IdentityT * m) g => (a -> b -> c -> d -> e -> g) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e -> IdentityT * m g Source #

liftA6 :: Suitable (IdentityT * m) h => (a -> b -> c -> d -> e -> g -> h) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e -> IdentityT * m g -> IdentityT * m h Source #

liftA7 :: Suitable (IdentityT * m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e -> IdentityT * m g -> IdentityT * m h -> IdentityT * m i Source #

liftA8 :: Suitable (IdentityT * m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e -> IdentityT * m g -> IdentityT * m h -> IdentityT * m i -> IdentityT * m j Source #

liftA9 :: Suitable (IdentityT * m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c -> IdentityT * m d -> IdentityT * m e -> IdentityT * m g -> IdentityT * m h -> IdentityT * m i -> IdentityT * m j -> IdentityT * m k Source #

Monad m => Applicative (ExceptT e m) Source # 

Methods

pure :: Suitable (ExceptT e m) a => a -> ExceptT e m a Source #

(<*>) :: Suitable (ExceptT e m) b => ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b Source #

(*>) :: Suitable (ExceptT e m) b => ExceptT e m a -> ExceptT e m b -> ExceptT e m b Source #

(<*) :: Suitable (ExceptT e m) a => ExceptT e m a -> ExceptT e m b -> ExceptT e m a Source #

liftA :: Suitable (ExceptT e m) b => (Vect xs -> b) -> AppVect (ExceptT e m) xs -> ExceptT e m b Source #

liftA2 :: Suitable (ExceptT e m) c => (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c Source #

liftA3 :: Suitable (ExceptT e m) d => (a -> b -> c -> d) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d Source #

liftA4 :: Suitable (ExceptT e m) e => (a -> b -> c -> d -> e) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e Source #

liftA5 :: Suitable (ExceptT e m) g => (a -> b -> c -> d -> e -> g) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e -> ExceptT e m g Source #

liftA6 :: Suitable (ExceptT e m) h => (a -> b -> c -> d -> e -> g -> h) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e -> ExceptT e m g -> ExceptT e m h Source #

liftA7 :: Suitable (ExceptT e m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e -> ExceptT e m g -> ExceptT e m h -> ExceptT e m i Source #

liftA8 :: Suitable (ExceptT e m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e -> ExceptT e m g -> ExceptT e m h -> ExceptT e m i -> ExceptT e m j Source #

liftA9 :: Suitable (ExceptT e m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c -> ExceptT e m d -> ExceptT e m e -> ExceptT e m g -> ExceptT e m h -> ExceptT e m i -> ExceptT e m j -> ExceptT e m k Source #

Monad m => Applicative (WriterT s m) Source # 

Methods

pure :: Suitable (WriterT s m) a => a -> WriterT s m a Source #

(<*>) :: Suitable (WriterT s m) b => WriterT s m (a -> b) -> WriterT s m a -> WriterT s m b Source #

(*>) :: Suitable (WriterT s m) b => WriterT s m a -> WriterT s m b -> WriterT s m b Source #

(<*) :: Suitable (WriterT s m) a => WriterT s m a -> WriterT s m b -> WriterT s m a Source #

liftA :: Suitable (WriterT s m) b => (Vect xs -> b) -> AppVect (WriterT s m) xs -> WriterT s m b Source #

liftA2 :: Suitable (WriterT s m) c => (a -> b -> c) -> WriterT s m a -> WriterT s m b -> WriterT s m c Source #

liftA3 :: Suitable (WriterT s m) d => (a -> b -> c -> d) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d Source #

liftA4 :: Suitable (WriterT s m) e => (a -> b -> c -> d -> e) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e Source #

liftA5 :: Suitable (WriterT s m) g => (a -> b -> c -> d -> e -> g) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e -> WriterT s m g Source #

liftA6 :: Suitable (WriterT s m) h => (a -> b -> c -> d -> e -> g -> h) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e -> WriterT s m g -> WriterT s m h Source #

liftA7 :: Suitable (WriterT s m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e -> WriterT s m g -> WriterT s m h -> WriterT s m i Source #

liftA8 :: Suitable (WriterT s m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e -> WriterT s m g -> WriterT s m h -> WriterT s m i -> WriterT s m j Source #

liftA9 :: Suitable (WriterT s m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> WriterT s m a -> WriterT s m b -> WriterT s m c -> WriterT s m d -> WriterT s m e -> WriterT s m g -> WriterT s m h -> WriterT s m i -> WriterT s m j -> WriterT s m k Source #

Applicative m => Applicative (ReaderT * r m) Source # 

Methods

pure :: Suitable (ReaderT * r m) a => a -> ReaderT * r m a Source #

(<*>) :: Suitable (ReaderT * r m) b => ReaderT * r m (a -> b) -> ReaderT * r m a -> ReaderT * r m b Source #

(*>) :: Suitable (ReaderT * r m) b => ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m b Source #

(<*) :: Suitable (ReaderT * r m) a => ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m a Source #

liftA :: Suitable (ReaderT * r m) b => (Vect xs -> b) -> AppVect (ReaderT * r m) xs -> ReaderT * r m b Source #

liftA2 :: Suitable (ReaderT * r m) c => (a -> b -> c) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c Source #

liftA3 :: Suitable (ReaderT * r m) d => (a -> b -> c -> d) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d Source #

liftA4 :: Suitable (ReaderT * r m) e => (a -> b -> c -> d -> e) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e Source #

liftA5 :: Suitable (ReaderT * r m) g => (a -> b -> c -> d -> e -> g) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g Source #

liftA6 :: Suitable (ReaderT * r m) h => (a -> b -> c -> d -> e -> g -> h) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h Source #

liftA7 :: Suitable (ReaderT * r m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i Source #

liftA8 :: Suitable (ReaderT * r m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i -> ReaderT * r m j Source #

liftA9 :: Suitable (ReaderT * r m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i -> ReaderT * r m j -> ReaderT * r m k Source #

Applicative (ContT * r m) Source # 

Methods

pure :: Suitable (ContT * r m) a => a -> ContT * r m a Source #

(<*>) :: Suitable (ContT * r m) b => ContT * r m (a -> b) -> ContT * r m a -> ContT * r m b Source #

(*>) :: Suitable (ContT * r m) b => ContT * r m a -> ContT * r m b -> ContT * r m b Source #

(<*) :: Suitable (ContT * r m) a => ContT * r m a -> ContT * r m b -> ContT * r m a Source #

liftA :: Suitable (ContT * r m) b => (Vect xs -> b) -> AppVect (ContT * r m) xs -> ContT * r m b Source #

liftA2 :: Suitable (ContT * r m) c => (a -> b -> c) -> ContT * r m a -> ContT * r m b -> ContT * r m c Source #

liftA3 :: Suitable (ContT * r m) d => (a -> b -> c -> d) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d Source #

liftA4 :: Suitable (ContT * r m) e => (a -> b -> c -> d -> e) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e Source #

liftA5 :: Suitable (ContT * r m) g => (a -> b -> c -> d -> e -> g) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e -> ContT * r m g Source #

liftA6 :: Suitable (ContT * r m) h => (a -> b -> c -> d -> e -> g -> h) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e -> ContT * r m g -> ContT * r m h Source #

liftA7 :: Suitable (ContT * r m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e -> ContT * r m g -> ContT * r m h -> ContT * r m i Source #

liftA8 :: Suitable (ContT * r m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e -> ContT * r m g -> ContT * r m h -> ContT * r m i -> ContT * r m j Source #

liftA9 :: Suitable (ContT * r m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> ContT * r m a -> ContT * r m b -> ContT * r m c -> ContT * r m d -> ContT * r m e -> ContT * r m g -> ContT * r m h -> ContT * r m i -> ContT * r m j -> ContT * r m k Source #

class Applicative f => Monad f where Source #

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.

Instances of Monad should satisfy the following laws:

Furthermore, the Monad and Applicative operations should relate as follows:

The above laws imply:

and that pure and (<*>) satisfy the applicative functor laws.

The instances of Monad for lists, Maybe and IO defined in the "Prelude" satisfy these laws.

Minimal complete definition

(>>=)

Methods

(>>=) :: Suitable f b => f a -> (a -> f b) -> f b infixl 1 Source #

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

Instances

Monad [] Source # 

Methods

(>>=) :: Suitable [] b => [a] -> (a -> [b]) -> [b] Source #

Monad Maybe Source # 

Methods

(>>=) :: Suitable Maybe b => Maybe a -> (a -> Maybe b) -> Maybe b Source #

Monad IO Source # 

Methods

(>>=) :: Suitable IO b => IO a -> (a -> IO b) -> IO b Source #

Monad Identity Source # 

Methods

(>>=) :: Suitable Identity b => Identity a -> (a -> Identity b) -> Identity b Source #

Monad Tree Source # 

Methods

(>>=) :: Suitable Tree b => Tree a -> (a -> Tree b) -> Tree b Source #

Monad Seq Source # 

Methods

(>>=) :: Suitable Seq b => Seq a -> (a -> Seq b) -> Seq b Source #

Monad Set Source # 

Methods

(>>=) :: Suitable Set b => Set a -> (a -> Set b) -> Set b Source #

Monad IntSet Source # 

Methods

(>>=) :: Suitable IntSet b => IntSet a -> (a -> IntSet b) -> IntSet b Source #

Monad ((->) a) Source # 

Methods

(>>=) :: Suitable ((->) a) b => (a -> a) -> (a -> a -> b) -> a -> b Source #

Monad (Either a) Source # 

Methods

(>>=) :: Suitable (Either a) b => Either a a -> (a -> Either a b) -> Either a b Source #

Monoid a => Monad ((,) a) Source # 

Methods

(>>=) :: Suitable ((,) a) b => (a, a) -> (a -> (a, b)) -> (a, b) Source #

Monad m => Monad (MaybeT m) Source # 

Methods

(>>=) :: Suitable (MaybeT m) b => MaybeT m a -> (a -> MaybeT m b) -> MaybeT m b Source #

Monad m => Monad (StateT s m) Source # 

Methods

(>>=) :: Suitable (StateT s m) b => StateT s m a -> (a -> StateT s m b) -> StateT s m b Source #

Monad m => Monad (StateT s m) Source # 

Methods

(>>=) :: Suitable (StateT s m) b => StateT s m a -> (a -> StateT s m b) -> StateT s m b Source #

Monad m => Monad (IdentityT * m) Source # 

Methods

(>>=) :: Suitable (IdentityT * m) b => IdentityT * m a -> (a -> IdentityT * m b) -> IdentityT * m b Source #

Monad m => Monad (ExceptT e m) Source # 

Methods

(>>=) :: Suitable (ExceptT e m) b => ExceptT e m a -> (a -> ExceptT e m b) -> ExceptT e m b Source #

Monad m => Monad (WriterT s m) Source # 

Methods

(>>=) :: Suitable (WriterT s m) b => WriterT s m a -> (a -> WriterT s m b) -> WriterT s m b Source #

Monad m => Monad (ReaderT * r m) Source # 

Methods

(>>=) :: Suitable (ReaderT * r m) b => ReaderT * r m a -> (a -> ReaderT * r m b) -> ReaderT * r m b Source #

Monad (ContT * r m) Source # 

Methods

(>>=) :: Suitable (ContT * r m) b => ContT * r m a -> (a -> ContT * r m b) -> ContT * r m b Source #

class Applicative f => Alternative f where Source #

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

Minimal complete definition

empty, (<|>)

Methods

empty :: Suitable f a => f a Source #

The identity of <|>

(<|>) :: Suitable f a => f a -> f a -> f a infixl 3 Source #

An associative binary operation

some :: Suitable f [a] => f a -> f [a] Source #

One or more.

many :: Suitable f [a] => f a -> f [a] Source #

Zero or more.

Instances

Alternative [] Source # 

Methods

empty :: Suitable [] a => [a] Source #

(<|>) :: Suitable [] a => [a] -> [a] -> [a] Source #

some :: Suitable [] [a] => [a] -> [[a]] Source #

many :: Suitable [] [a] => [a] -> [[a]] Source #

Alternative Maybe Source # 

Methods

empty :: Suitable Maybe a => Maybe a Source #

(<|>) :: Suitable Maybe a => Maybe a -> Maybe a -> Maybe a Source #

some :: Suitable Maybe [a] => Maybe a -> Maybe [a] Source #

many :: Suitable Maybe [a] => Maybe a -> Maybe [a] Source #

Alternative IO Source # 

Methods

empty :: Suitable IO a => IO a Source #

(<|>) :: Suitable IO a => IO a -> IO a -> IO a Source #

some :: Suitable IO [a] => IO a -> IO [a] Source #

many :: Suitable IO [a] => IO a -> IO [a] Source #

Alternative Seq Source # 

Methods

empty :: Suitable Seq a => Seq a Source #

(<|>) :: Suitable Seq a => Seq a -> Seq a -> Seq a Source #

some :: Suitable Seq [a] => Seq a -> Seq [a] Source #

many :: Suitable Seq [a] => Seq a -> Seq [a] Source #

Alternative Set Source # 

Methods

empty :: Suitable Set a => Set a Source #

(<|>) :: Suitable Set a => Set a -> Set a -> Set a Source #

some :: Suitable Set [a] => Set a -> Set [a] Source #

many :: Suitable Set [a] => Set a -> Set [a] Source #

Alternative IntSet Source # 
Monad m => Alternative (MaybeT m) Source # 

Methods

empty :: Suitable (MaybeT m) a => MaybeT m a Source #

(<|>) :: Suitable (MaybeT m) a => MaybeT m a -> MaybeT m a -> MaybeT m a Source #

some :: Suitable (MaybeT m) [a] => MaybeT m a -> MaybeT m [a] Source #

many :: Suitable (MaybeT m) [a] => MaybeT m a -> MaybeT m [a] Source #

(Monad m, Alternative m) => Alternative (StateT s m) Source # 

Methods

empty :: Suitable (StateT s m) a => StateT s m a Source #

(<|>) :: Suitable (StateT s m) a => StateT s m a -> StateT s m a -> StateT s m a Source #

some :: Suitable (StateT s m) [a] => StateT s m a -> StateT s m [a] Source #

many :: Suitable (StateT s m) [a] => StateT s m a -> StateT s m [a] Source #

(Monad m, Alternative m) => Alternative (StateT s m) Source # 

Methods

empty :: Suitable (StateT s m) a => StateT s m a Source #

(<|>) :: Suitable (StateT s m) a => StateT s m a -> StateT s m a -> StateT s m a Source #

some :: Suitable (StateT s m) [a] => StateT s m a -> StateT s m [a] Source #

many :: Suitable (StateT s m) [a] => StateT s m a -> StateT s m [a] Source #

(Monad m, Monoid e) => Alternative (ExceptT e m) Source # 

Methods

empty :: Suitable (ExceptT e m) a => ExceptT e m a Source #

(<|>) :: Suitable (ExceptT e m) a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

some :: Suitable (ExceptT e m) [a] => ExceptT e m a -> ExceptT e m [a] Source #

many :: Suitable (ExceptT e m) [a] => ExceptT e m a -> ExceptT e m [a] Source #

Alternative m => Alternative (ReaderT * r m) Source # 

Methods

empty :: Suitable (ReaderT * r m) a => ReaderT * r m a Source #

(<|>) :: Suitable (ReaderT * r m) a => ReaderT * r m a -> ReaderT * r m a -> ReaderT * r m a Source #

some :: Suitable (ReaderT * r m) [a] => ReaderT * r m a -> ReaderT * r m [a] Source #

many :: Suitable (ReaderT * r m) [a] => ReaderT * r m a -> ReaderT * r m [a] Source #

class (Foldable t, Functor t) => Traversable t where Source #

Functors representing data structures that can be traversed from left to right.

A definition of traverse must satisfy the following laws:

naturality
t . traverse f = traverse (t . f) for every applicative transformation t
identity
traverse Identity = Identity
composition
traverse (Compose . fmap g . f) = Compose . fmap (traverse g) . traverse f

A definition of sequenceA must satisfy the following laws:

naturality
t . sequenceA = sequenceA . fmap t for every applicative transformation t
identity
sequenceA . fmap Identity = Identity
composition
sequenceA . fmap Compose = Compose . fmap sequenceA . sequenceA

where an applicative transformation is a function

t :: (Applicative f, Applicative g) => f a -> g a

preserving the Applicative operations, i.e.

and the identity functor Identity and composition of functors Compose are defined as

  newtype Identity a = Identity a

  instance Functor Identity where
    fmap f (Identity x) = Identity (f x)

  instance Applicative Identity where
    pure x = Identity x
    Identity f <*> Identity x = Identity (f x)

  newtype Compose f g a = Compose (f (g a))

  instance (Functor f, Functor g) => Functor (Compose f g) where
    fmap f (Compose x) = Compose (fmap (fmap f) x)

  instance (Applicative f, Applicative g) => Applicative (Compose f g) where
    pure x = Compose (pure (pure x))
    Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)

(The naturality law is implied by parametricity.)

Instances are similar to Functor, e.g. given a data type

data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)

a suitable instance would be

instance Traversable Tree where
   traverse f Empty = pure Empty
   traverse f (Leaf x) = Leaf <$> f x
   traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r

This is suitable even for abstract types, as the laws for <*> imply a form of associativity.

The superclass instances should satisfy the following:

  • In the Functor instance, fmap should be equivalent to traversal with the identity applicative functor (fmapDefault).
  • In the Foldable instance, foldMap should be equivalent to traversal with a constant applicative functor (foldMapDefault).

Minimal complete definition

traverse

Methods

traverse :: (Suitable t b, Applicative f, Suitable f (t b)) => (a -> f b) -> t a -> f (t b) Source #

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see traverse_.

Instances

Traversable [] Source # 

Methods

traverse :: (Suitable [] b, Applicative f, Suitable f [b]) => (a -> f b) -> [a] -> f [b] Source #

Traversable Maybe Source # 

Methods

traverse :: (Suitable Maybe b, Applicative f, Suitable f (Maybe b)) => (a -> f b) -> Maybe a -> f (Maybe b) Source #

Traversable Identity Source # 

Methods

traverse :: (Suitable Identity b, Applicative f, Suitable f (Identity b)) => (a -> f b) -> Identity a -> f (Identity b) Source #

Traversable (Either a) Source # 

Methods

traverse :: (Suitable (Either a) b, Applicative f, Suitable f (Either a b)) => (a -> f b) -> Either a a -> f (Either a b) Source #

Traversable ((,) a) Source # 

Methods

traverse :: (Suitable ((,) a) b, Applicative f, Suitable f (a, b)) => (a -> f b) -> (a, a) -> f (a, b) Source #

Horrible type-level stuff

data Vect xs where Source #

A heterogeneous list, for storing the arguments to liftA. (There has to be a better way to do this).

Constructors

Nil :: Vect '[] 
(:-) :: x -> Vect xs -> Vect (x ': xs) infixr 5 

data AppVect f xs where Source #

Another heterogeneous list, for storing the arguments to liftA, wrapped in their applicatives.

Constructors

NilA :: AppVect f '[] 
(:*) :: f x -> AppVect f xs -> AppVect f (x ': xs) infixr 5 

liftAP :: Applicative f => (Vect xs -> b) -> AppVect f xs -> f b Source #

A definition of liftA which uses the Prelude's (<*>).

liftAM :: (Monad f, Suitable f b) => (Vect xs -> b) -> AppVect f xs -> f b Source #

A definition of liftA which uses 's (>>=).

Useful functions

guard :: (Alternative f, Suitable f ()) => Bool -> f () Source #

guard b is pure () if b is True, and empty if b is False.

ensure :: (Alternative f, Suitable f a) => Bool -> f a -> f a Source #

ensure b x is x if b is True, and empty if b is False.

(<**>) :: (Applicative f, Suitable f b) => f a -> f (a -> b) -> f b Source #

A variant of <*> with the arguments reversed.

(<$>) :: (Functor f, Suitable f b) => (a -> b) -> f a -> f b infixl 4 Source #

An infix synonym for fmap.

The name of this operator is an allusion to $. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas $ is function application, <$> is function application lifted over a Functor.

Examples

Convert from a Maybe Int to a Maybe String using show:

>>> show <$> Nothing
Nothing
>>> show <$> Just 3
Just "3"

Convert from an Either Int Int to an Either Int String using show:

>>> show <$> Left 17
Left 17
>>> show <$> Right 17
Right "17"

Double each element of a list:

>>> (*2) <$> [1,2,3]
[2,4,6]

Apply even to the second element of a pair:

>>> even <$> (2,2)
(2,True)

(=<<) :: (Monad f, Suitable f b) => (a -> f b) -> f a -> f b infixr 1 Source #

A flipped version of >>=

(<=<) :: (Monad f, Suitable f c) => (b -> f c) -> (a -> f b) -> a -> f c infixr 1 Source #

Right-to-left Kleisli composition of monads. (>=>), with the arguments flipped.

Note how this operator resembles function composition (.):

(.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

(>=>) :: (Monad f, Suitable f c) => (a -> f b) -> (b -> f c) -> a -> f c infixl 1 Source #

Left-to-right Kleisli composition of monads.

foldM :: (Foldable t, Monad m, Suitable m b) => (b -> a -> m b) -> b -> t a -> m b Source #

Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.

traverse_ :: (Applicative f, Foldable t, Suitable f ()) => (a -> f b) -> t a -> f () Source #

Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see traverse.

sequenceA :: (Applicative f, Suitable t a, Suitable f (t a), Traversable t) => t (f a) -> f (t a) Source #

Evaluate each action in the structure from left to right, and and collect the results. For a version that ignores the results see sequenceA_.

sequenceA_ :: (Foldable t, Applicative f, Suitable f ()) => t (f a) -> f () Source #

Evaluate each action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see sequenceA.

mapAccumL :: (Traversable t, Suitable t c) => (a -> b -> (a, c)) -> a -> t b -> (a, t c) Source #

The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

replicateM :: (Applicative m, Suitable m [a]) => Int -> m a -> m [a] Source #

replicateM n act performs the action n times, gathering the results.

void :: (Functor f, Suitable f ()) => f a -> f () Source #

void value discards or ignores the result of evaluation, such as the return value of an IO action.

Examples

Replace the contents of a Maybe Int with unit:

>>> void Nothing
Nothing
>>> void (Just 3)
Just ()

Replace the contents of an Either Int Int with unit, resulting in an Either Int '()':

>>> void (Left 8675309)
Left 8675309
>>> void (Right 8675309)
Right ()

Replace every element of a list with unit:

>>> void [1,2,3]
[(),(),()]

Replace the second element of a pair with unit:

>>> void (1,2)
(1,())

Discard the result of an IO action:

>>> traverse print [1,2]
1
2
[(),()]
>>> void $ traverse print [1,2]
1
2

forever :: (Applicative f, Suitable f b) => f a -> f b Source #

forever act repeats the action infinitely.

for_ :: (Foldable t, Applicative f, Suitable f ()) => t a -> (a -> f b) -> f () Source #

for_ is traverse_ with its arguments flipped. For a version that doesn't ignore the results see for.

>>> for_ [1..4] print
1
2
3
4

Syntax

ifThenElse :: Bool -> a -> a -> a Source #

Function to which the if ... then ... else syntax desugars to

fail :: String -> a Source #

Called on a failed pattern match in a monadic bind. To be avoided.

(>>) :: (Applicative f, Suitable f b) => f a -> f b -> f b Source #

Sequence two actions, discarding the result of the first. Alias for (*>).

return :: (Applicative f, Suitable f a) => a -> f a Source #

Alias for pure.