The • operator forms a bifunctor [Set,Set]op×Cont→Cont.
The map on objects is the application of (•) and the map on morphisms, the map
on morphisms relies on the naturality square of the functors in Set
The inversion from (•) means that every monad on Set becomes a comonad in Cont when applied
with (•).
Proposition
Given a monad m:Set→Set, the functor m•:Cont→Cont is a comonad.
finish transforming between monads in set to comonads in cont
ContComonad : (Monad Set e) -> Comonad Cont (FApplyFunctor e)
Additionally we are going to need the following property to run programs with IO: δ : m • (a ▷ b) ⇒ m • (a ▷ m • b)
Proposition
Functorial application distributes to the right of (⊳) when m is a monad.
δ : {a, b : _} -> m • (a ▷ b) =%> m • (a ▷ m • b) δ = id <! (\x, y => joinSnd {a = a.response x.ex1, b = b.response . x.ex2 } y )
Relation to Monadic lenses
Monadic lenses as defined by \ref{monadicLens} are lenses where the backward morphism
is wrapped in a monad in set. We can reproduce the results from this paper but in Cont
by using functorial application in the domain of any dependent lens.
Proposition
Lenses using the functor application in their domain are monadic lenses
The definition of a monadic lens is a lens MLens s t a b where the backward morphism end in f t instead
of t.
We leave the proof to be done by observation, to help, here are the two definitions superimposed:
a -> (s * (t -> f b)) -- Monadic lenses
(_ : a) -> Σ (_ : s) | t -> f b -- Dependent lenses f • (a, b) =&> (s, t)
Some helper functions to manipulate functorial applications
find a better spot for that
%unbound_implicits onexportcounit : (0 m : Type -> Type) -> Monad m => m • a =%> acounit _ = id <! \_ => pureexportcojoin : (0 m : Type -> Type) -> Monad m => m • a =%> m • m • acojoin m = id <! \_ => join