data Cofree f amkCofree :: forall f a. a -> f (Cofree f a) -> Cofree f ahead :: forall f a. Cofree f a -> atail :: forall f a. Cofree f a -> f (Cofree f a)instance functorCofree :: (Functor f) => Functor (Cofree f)instance foldableCofree :: (Foldable f) => Foldable (Cofree f)instance traversableCofree :: (Traversable f) => Traversable (Cofree f)instance extendCofree :: (Functor f) => Extend (Cofree f)instance comonadCofree :: (Functor f) => Comonad (Cofree f)instance applyCofree :: (Apply f) => Apply (Cofree f)instance applicativeCofree :: (Applicative f) => Applicative (Cofree f)instance bindCofree :: (MonadPlus f) => Bind (Cofree f)instance monadCofree :: (MonadPlus f) => Monad (Cofree f)data Free f a
= Pure a
| Free (f (Free f a))
| Gosub (forall s. (forall r. (Unit -> Free f r) -> (r -> Free f a) -> s) -> s)type FreeC f = Free (Coyoneda f)class MonadFree f m where
wrap :: forall a. f (m a) -> m ainstance functorFree :: (Functor f) => Functor (Free f)instance applyFree :: (Functor f) => Apply (Free f)instance applicativeFree :: (Functor f) => Applicative (Free f)instance bindFree :: (Functor f) => Bind (Free f)instance monadFree :: (Functor f) => Monad (Free f)instance monadTransFree :: MonadTrans Freeinstance monadFreeFree :: (Functor f) => MonadFree f (Free f)liftF :: forall f m a. (Functor f, Monad m, MonadFree f m) => f a -> m apureF :: forall f a. (Applicative f) => a -> Free f aliftFC :: forall f a. f a -> FreeC f apureFC :: forall f a. (Applicative f) => a -> FreeC f amapF :: forall f g a. (Functor f, Functor g) => Natural f g -> Free f a -> Free g ainjC :: forall f g a. (Inject f g) => FreeC f a -> FreeC g arunFree :: forall f a. (Functor f) => (f (Free f a) -> Free f a) -> Free f a -> arunFree runs a computation of type Free f a, using a function which unwraps a single layer of
the functor f at a time.
runFreeM :: forall f m a. (Functor f, MonadRec m) => (f (Free f a) -> m (Free f a)) -> Free f a -> m arunFreeM runs a compuation of type Free f a in any Monad which supports tail recursion.
See the MonadRec type class for more details.
runFreeC :: forall f a. (forall a. f a -> a) -> FreeC f a -> arunFreeC is the equivalent of runFree for type constructors transformed with Coyoneda,
hence we have no requirement that f be a Functor.
runFreeCM :: forall f m a. (MonadRec m) => Natural f m -> FreeC f a -> m arunFreeCM is the equivalent of runFreeM for type constructors transformed with Coyoneda,
hence we have no requirement that f be a Functor.
type Trampoline = Free Lazydone :: forall a. a -> Trampoline asuspend :: forall a. Trampoline a -> Trampoline adelay' :: forall a. Lazy a -> Trampoline adelay :: forall a. (Unit -> a) -> Trampoline arunTrampoline :: forall a. Trampoline a -> anewtype CoyonedaF f a i
= CoyonedaF { fi :: f i, k :: i -> a }newtype Coyoneda f a
= Coyoneda (Exists (CoyonedaF f a))type Natural f g = forall a. f a -> g ainstance functorCoyoneda :: Functor (Coyoneda f)instance applyCoyoneda :: (Apply f) => Apply (Coyoneda f)instance applicativeCoyoneda :: (Applicative f) => Applicative (Coyoneda f)instance bindCoyoneda :: (Bind f) => Bind (Coyoneda f)instance monadCoyoneda :: (Monad f) => Monad (Coyoneda f)instance monadTransCoyoneda :: MonadTrans Coyonedainstance extendCoyoneda :: (Extend w) => Extend (Coyoneda w)instance comonadCoyoneda :: (Comonad w) => Comonad (Coyoneda w)coyoneda :: forall f a b. (a -> b) -> f a -> Coyoneda f bliftCoyoneda :: forall f a. f a -> Coyoneda f alowerCoyoneda :: forall f a. (Functor f) => Coyoneda f a -> f aliftCoyonedaT :: forall f g. Natural f g -> Natural (Coyoneda f) (Coyoneda g)liftCoyonedaTF :: forall f g. (Functor g) => Natural f g -> Natural (Coyoneda f) gnewtype Yoneda f a
= Yoneda (forall b. (a -> b) -> f b)instance functorYoneda :: Functor (Yoneda f)instance applyYoneda :: (Apply f) => Apply (Yoneda f)instance applicativeYoneda :: (Applicative f) => Applicative (Yoneda f)instance bindCoyoneda :: (Bind f) => Bind (Yoneda f)instance monadYoneda :: (Monad f) => Monad (Yoneda f)instance monadTransYoneda :: MonadTrans Yonedainstance extendYoneda :: (Extend w) => Extend (Yoneda w)instance comonadYoneda :: (Comonad w) => Comonad (Yoneda w)runYoneda :: forall f a b. Yoneda f a -> (a -> b) -> f bliftYoneda :: forall f a. (Functor f) => f a -> Yoneda f alowerYoneda :: forall f a. Yoneda f a -> f a