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();
}
}