ap package:free

The free Applicative for a Functor f.
The faster free Applicative.
The free Applicative for a Functor f.
The free Applicative for a Functor f.
"Applicative Effects in Free Monads" Often times, the (\<*\>) operator can be more efficient than ap. Conventional free monads don't provide any means of modeling this. The free monad can be modified to make use of an underlying applicative. But it does require some laws, or else the (\<*\>) = ap law is broken. When interpreting this free monad with foldFree, the natural transformation must be an applicative homomorphism. An applicative homomorphism hm :: (Applicative f, Applicative g) => f x -> g x will satisfy these laws.
  • hm (pure a) = pure a
  • hm (f <*> a) = hm f <*> hm a
This is based on the "Applicative Effects in Free Monads" series of articles by Will Fancher
Given an applicative, the free monad transformer.
The free Applicative for a Functor f.
The free Applicative transformer for a Functor f over Applicative g.
Given a natural transformation from f to g this gives a monoidal natural transformation from Ap f to Ap g.
Tear down a free Applicative using iteration.
A version of lift that can be used with just a Functor for f.
Interprets the free applicative functor over f using the semantics for pure and <*> given by the Applicative instance for f.
retractApp == runAp id
Given a natural transformation from f to g, this gives a canonical monoidal natural transformation from Ap f to g.
runAp t == retractApp . hoistApp t
Perform a monoidal analysis over free applicative value. Example:
count :: Ap f a -> Int
count = getSum . runAp_ (\_ -> Sum 1)
Given a natural transformation from f to g this gives a monoidal natural transformation from Ap f to Ap g.
Given a natural transformation from f to f' this gives a monoidal natural transformation from ApF f g to ApF f' g.