The free Applicative for a Functor f.
Constructors
Ap_runAp :: forall (g :: Type -> Type). Applicative g => (forall x. f x -> g x) -> g a
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulefree-5.2Haskell2010
Final encoding of free Applicative functors.
Compared to the free monad, they are less expressive. However, they are also more flexible to inspect and interpret, as the number of ways in which the values can be nested is more limited.
The free Applicative for a Functor f.
Ap_runAp :: forall (g :: Type -> Type). Applicative g => (forall x. f x -> g x) -> g aGiven a natural transformation from f to g, this gives a canonical monoidal natural transformation from Ap f to g.
runAp t == retractApp . hoistApp tPerform a monoidal analysis over free applicative value.
Example:
count :: Ap f a -> Int
count = getSum . runAp_ (\_ -> Sum 1)
A version of lift that can be used with just a Functor for f.
Given a natural transformation from f to g this gives a monoidal natural transformation from Ap f to Ap g.