use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Functor visit(FQLPPProgram env, MapConst ic) {
Triple<Category, Category, Mapping<String, String, String, String>> xxx = toMapping(env, ic);
Mapping<String, String, String, String> I = xxx.third;
FUNCTION f = p0 -> {
Path p = (Path) p0;
return I.apply(p);
};
Functor et = new Functor(xxx.first, xxx.second, x -> I.nm.get(x), f);
et.mapping0 = xxx.third;
return et;
}
use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, Proj e) {
Functor l = e.l.accept(env, this);
Functor r = e.r.accept(env, this);
if (!l.source.equals(r.source)) {
throw new RuntimeException("Source category does not match");
}
if (!l.target.equals(r.target)) {
throw new RuntimeException("Target category does not match");
}
if (l.target.equals(FinSet.FinSet)) {
return e.proj1 ? Inst.get(l.source).first(l, r) : Inst.get(l.source).second(l, r);
} else if (l.target.equals(FinCat.FinCat)) {
return e.proj1 ? FunCat.get(l.source).first(l, r) : FunCat.get(l.source).second(l, r);
} else {
throw new RuntimeException("report this error to ryan");
}
}
use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, TransExp.Iso e) {
Functor l = e.l.accept(env, this);
Functor r = e.r.accept(env, this);
if (!l.source.equals(r.source)) {
throw new RuntimeException("Source categories do not match: " + l.source + "\nand\n" + r.source);
}
if (l.source.isInfinite()) {
throw new RuntimeException("Source category must be finite.");
}
if (!l.target.equals(FinSet.FinSet)) {
throw new RuntimeException("Target category must be Set.");
}
Optional<Pair<Transform, Transform>> k = Inst.get(l.source).iso(l, r);
if (!k.isPresent()) {
throw new RuntimeException("Not isomorphic: " + e.l + " and " + e.r);
}
return e.lToR ? k.get().first : k.get().second;
}
use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, Whisker e) {
Functor F = e.func.accept(env, this);
Transform T = e.trans.accept(env, this);
return e.left ? Transform.leftWhisker(F, T) : Transform.rightWhisker(F, T);
}
use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.
the class CatOps method visit.
@Override
public Transform visit(FQLPPProgram env, TransExp.Eval e) {
Functor a = e.a.accept(env, this);
Functor b = e.b.accept(env, this);
if (!a.source.equals(b.source) || a.source.isInfinite() || !a.target.equals(FinSet.FinSet)) {
throw new RuntimeException("Cannot eval " + a + " and " + b);
}
return Inst.get(a.source).eval(a, b);
}
Aggregations