Search in sources :

Example 1 with CoMonad

use of catdata.fqlpp.cat.CoMonad in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Category visit(FQLPPProgram env, Kleisli e) {
    FunctorExp f0 = env.ftrs.get(e.F);
    if (f0 == null) {
        throw new RuntimeException("Missing functor: " + e.F);
    }
    TransExp ret0 = env.trans.get(e.unit);
    if (ret0 == null) {
        throw new RuntimeException("Missing transform: " + e.unit);
    }
    TransExp join0 = env.trans.get(e.join);
    if (join0 == null) {
        throw new RuntimeException("Missing transform: " + e.join);
    }
    Functor F = f0.accept(env, this);
    Transform ret = ret0.accept(env, this);
    Transform join = join0.accept(env, this);
    if (e.isCo) {
        CoMonad m = new CoMonad(F, ret, join);
        return m.cokleisli();
    } else {
        Monad m = new Monad(F, ret, join);
        return m.kleisli();
    }
}
Also used : Functor(catdata.fqlpp.cat.Functor) Transform(catdata.fqlpp.cat.Transform) CoMonad(catdata.fqlpp.cat.CoMonad) Monad(catdata.fqlpp.cat.Monad) CoMonad(catdata.fqlpp.cat.CoMonad)

Aggregations

CoMonad (catdata.fqlpp.cat.CoMonad)1 Functor (catdata.fqlpp.cat.Functor)1 Monad (catdata.fqlpp.cat.Monad)1 Transform (catdata.fqlpp.cat.Transform)1