Free-like data structure:
Haskell Community [Unofficial]
April 30, 2026
data Free f a
= Pure a
| Free (Free f (f a)) deriving Functor
-- f (a -> b) -> a -> f b
(??) :: Functor f => f (a -> b) -> a -> f b
fab ?? a = fmap ($ a) fab -- Copied fro Control.Lens
instance Functor f => Applicative (Free f) where
pure = Pure
Pure g <*> x = g <$> x
Free g <*> x = Free $ (flip (fmap . flip id) <$> g) <*> x
This is similar to the Free monad, but reversed. Is it the free Applicative or something? It seems similar to one of the proposals of bound.
Discussion in the ATmosphere