use of catdata.fqlpp.cat.Transform in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, ToMap e) {
Functor s = e.src.accept(env, this);
Functor t = e.dst.accept(env, this);
CatExp scat = resolve(env, e.s);
if (!(scat instanceof Const)) {
throw new RuntimeException("Source category of " + e + " is not a constant.");
}
// CatExp.Const scon = (CatExp.Const) scat;
CatExp tcat = resolve(env, e.t);
if (!(tcat instanceof Const)) {
throw new RuntimeException("Target category of " + e + " is not a constant.");
}
Const tcon = (Const) tcat;
// Signature ssig = new Signature(scon.nodes, scon.arrows, scon.eqs);
Signature<String, String> tsig = new Signature<>(tcon.nodes, tcon.arrows, tcon.eqs);
FUNCTION o = x -> {
Node n = (Node) x;
// Set src = (Set) s.applyO(n);
// Set dst = (Set) t.applyO(n);
Pair<String, List<String>> k = e.fun.get(n.name);
Signature<String, String>.Path fun = tsig.path(k.first, k.second);
// new Fn(src, dst, fun);
return fun;
};
return new Transform(s, t, o);
}
use of catdata.fqlpp.cat.Transform in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, TransExp.Prod e) {
Transform l = e.l.accept(env, this);
Transform r = e.r.accept(env, this);
if (!l.source.equals(r.source)) {
throw new RuntimeException("Source functors do not match");
}
if (!l.target.source.equals(r.target.source)) {
throw new RuntimeException("Categories do not match");
}
if (l.source.target.equals(FinSet.FinSet)) {
return Inst.get(l.target.source).pair(l, r);
} else if (l.source.target.equals(FinCat.FinCat)) {
return FunCat.get(l.target.source).pair(l, r);
} else {
throw new RuntimeException("Report this error to ryan.");
}
}
use of catdata.fqlpp.cat.Transform in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, PeterApply e) {
Transform t = e.t.accept(env, this);
Node n = t.source.source.toSig().new Node(e.node);
return (Transform) t.apply(n);
}
use of catdata.fqlpp.cat.Transform in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, SetSet e) {
Functor s = e.src.accept(env, this);
Functor t = e.dst.accept(env, this);
FUNCTION o = x -> {
Set set = (Set) x;
FQLPPEnvironment env2 = new FQLPPEnvironment(ENV);
// SetExp c = new SetExp.Const(set);
env2.sets.put(e.ob, set);
return e.fun.accept(env, new SetOps(env2));
};
return new Transform(s, t, o);
}
use of catdata.fqlpp.cat.Transform in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, ToInst e) {
Functor s = e.src.accept(env, this);
Functor t = e.dst.accept(env, this);
FUNCTION o = x -> {
Node n = (Node) x;
// Set src = (Set) s.applyO(n);
// Set dst = (Set) t.applyO(n);
Transform fun = e.fun.get(n.name).accept(env, this);
// new Fn(src, dst, fun);
return fun;
};
return new Transform(s, t, o);
}
Aggregations