use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Bool e) {
InstExp u = env.insts.get(e.unit);
if (u == null) {
throw new RuntimeException("Missing instance: " + e.unit);
}
if (!(u instanceof One)) {
throw new RuntimeException("Not a unit in " + e);
}
InstExp v = env.insts.get(e.prop);
if (v == null) {
throw new RuntimeException("Missing instance: " + e.prop);
}
if (!(v instanceof Two)) {
throw new RuntimeException("Not a prop in " + e);
}
return new Pair<>(e.unit, e.prop);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Inl e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof Plus)) {
throw new RuntimeException(e.obj + " is not a plus: " + x);
}
Plus y = (Plus) x;
return new Pair<>(y.a, e.obj);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Case e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof Plus)) {
throw new RuntimeException(e.obj + " is not a plus: " + x);
}
// InstExp.Plus y = (InstExp.Plus) x;
Pair<String, String> a = e.l.accept(env, this);
Pair<String, String> b = e.r.accept(env, this);
if (!a.second.equals(b.second)) {
throw new RuntimeException("Codomain mismatch: " + e + " with " + a.second + " and " + b.second);
}
return new Pair<>(e.obj, a.second);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Delta e) {
Pair<String, String> ht = e.h.type(env);
InstExp i1 = env.insts.get(e.src);
if (!(i1 instanceof InstExp.Delta)) {
throw new RuntimeException(i1 + " is not a delta in " + e);
}
String i1x = ((InstExp.Delta) i1).I;
if (!i1x.equals(ht.first)) {
throw new RuntimeException("Source mismatch on " + e + ": " + i1x + " and " + ht.first);
}
InstExp i2 = env.insts.get(e.dst);
if (!(i2 instanceof InstExp.Delta)) {
throw new RuntimeException(i2 + " is not a delta in " + e);
}
String i2x = ((InstExp.Delta) i2).I;
if (!i2x.equals(ht.second)) {
throw new RuntimeException("Target mismatch on " + e + ": " + i2x + " and " + ht.second);
}
return new Pair<>(e.src, e.dst);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, UnChi e) {
InstExp p = env.insts.get(e.a);
if (p == null) {
throw new RuntimeException("Missing instance " + e.a);
}
if (!(p instanceof Kernel)) {
throw new RuntimeException("Not a kernel " + e);
}
Kernel k = (Kernel) p;
Pair<String, String> trans = env.transforms.get(k.trans).type(env);
return new Pair<>(e.a, trans.first);
}
Aggregations