Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
A faster free applicative. Based on Dave Menendez's work.
- data ASeq f a where
- reduceASeq :: Applicative f => ASeq f u -> f u
- newtype Ap f a = Ap {}
- liftAp :: f a -> Ap f a
- retractAp :: Applicative f => Ap f a -> f a
- runAp :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a
- runAp_ :: Monoid m => (forall a. f a -> m) -> Ap f b -> m
- hoistASeq :: (forall x. f x -> g x) -> ASeq f a -> ASeq g a
- traverseASeq :: Applicative h => (forall x. f x -> h (g x)) -> ASeq f a -> h (ASeq g a)
- rebaseASeq :: ASeq f u -> (forall x. (x -> y) -> ASeq f x -> z) -> (v -> u -> y) -> ASeq f v -> z
- hoistAp :: (forall x. f x -> g x) -> Ap f a -> Ap g a
Documentation
reduceASeq :: Applicative f => ASeq f u -> f u Source
reduceASeq a sequence of applicative effects into an applicative.
The faster free Applicative
.
Monad m => MonadFraxl f (FreerT f m) Source | |
(Monad m, (∈) (* -> *) f r) => MonadFraxl f (Fraxl r m) Source | |
Functor (Ap f) Source | |
Applicative (Ap f) Source |
retractAp :: Applicative f => Ap f a -> f a Source
runAp :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a Source
Given a natural transformation from f
to g
, this gives a canonical monoidal natural transformation from
to Ap
fg
.
runAp t == retractApp . hoistApp t
runAp_ :: Monoid m => (forall a. f a -> m) -> Ap f b -> m Source
Perform a monoidal analysis over free applicative value.
Example:
count :: Ap f a -> Int count = getSum . runAp_ (\_ -> Sum 1)
hoistASeq :: (forall x. f x -> g x) -> ASeq f a -> ASeq g a Source
Transform a sequence of f
into a sequence of g
.
traverseASeq :: Applicative h => (forall x. f x -> h (g x)) -> ASeq f a -> h (ASeq g a) Source
Traverse a sequence with resepect to its interpretation type f
.
rebaseASeq :: ASeq f u -> (forall x. (x -> y) -> ASeq f x -> z) -> (v -> u -> y) -> ASeq f v -> z Source
It may not look like it, but this appends two sequences. See Dave Menendez's work for more explanation.