use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, TT e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof One)) {
throw new RuntimeException(e.obj + " is not a unit: " + x);
}
// InstExp.One y = (InstExp.One) x;
InstExp z = env.insts.get(e.tgt);
if (z == null) {
throw new RuntimeException("Missing " + e.tgt + " in " + e);
}
SigExp xt = x.type(env);
SigExp yt = z.type(env);
if (!xt.equals(yt)) {
throw new RuntimeException("Instances have different types in " + e + ": " + xt + " and " + yt);
}
return new Pair<>(e.tgt, 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, External e) {
InstExp src = env.insts.get(e.src);
if (src == null) {
throw new RuntimeException("Missing instance " + e.src);
}
InstExp dst = env.insts.get(e.dst);
if (dst == null) {
throw new RuntimeException("Missing instance " + e.src);
}
if (!(src instanceof InstExp.External)) {
throw new RuntimeException(e.src + " is not external.");
}
if (!(dst instanceof InstExp.External)) {
throw new RuntimeException(e.dst + " is not external.");
}
InstExp.External src0 = (InstExp.External) src;
InstExp.External dst0 = (InstExp.External) dst;
SigExp srct = src0.type(env);
SigExp dstt = dst0.type(env);
if (!srct.equals(dstt)) {
throw new RuntimeException("Instances not of same type on " + e + " are " + srct + " and " + dstt);
}
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, FF e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof Zero)) {
throw new RuntimeException(e.obj + " is not void: " + x);
}
// InstExp.One y = (InstExp.One) x;
InstExp z = env.insts.get(e.tgt);
if (z == null) {
throw new RuntimeException("Missing " + e.tgt + " in " + e);
}
SigExp xt = x.type(env);
SigExp yt = z.type(env);
if (!xt.equals(yt)) {
throw new RuntimeException("Instances have different types in " + e + ": " + xt + " and " + yt);
}
return new Pair<>(e.obj, e.tgt);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Pi e) {
Pair<String, String> ht = e.h.type(env);
InstExp i1 = env.insts.get(e.src);
if (!(i1 instanceof InstExp.Pi)) {
throw new RuntimeException(i1 + " is not a pi in " + e);
}
String i1x = ((InstExp.Pi) 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.Pi)) {
throw new RuntimeException(i2 + " is not a pi in " + e);
}
String i2x = ((InstExp.Pi) 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, Fst e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof Times)) {
throw new RuntimeException(e.obj + " is not a times: " + x);
}
Times y = (Times) x;
return new Pair<>(e.obj, y.a);
}
Aggregations