abstract Kleisli category
A thunk-force category consists of
- a category ,
- a functor ,
- a map that sends each object of to an arrow (i.e., is a “possibly unnatural transformation”), and
- a natural transformation
satisfying the following criteria:
- ,
- is a natural transformation,
- , and
- .
class Functor cat l => AbstractKleisli cat l where
thunk :: cat a (l a)
force :: cat (l a) a
It turns out that, for any monad , the Kleisli category of is an abstract Kleisli category. The functor is the monad itself.
instance Subhask.Monad cat m => AbstractKleisli (Subhask.Kleisli cat m) m where
-- ignoring the Kleisli newtype wrapper:
-- thunk :: cat a (m (m a))
-- force :: cat (m a) (m a)
thunk = Kleisli (return . return)
force = id