@Override public Functor visit(FQLProgram env, Prod e) { Functor l = e.l.accept(env, this); Functor r = e.r.accept(env, this); if (FinSet.FinSet.equals(l.target) && FinSet.FinSet.equals(r.target)) { if (!l.source.equals(r.source)) { throw new RuntimeException("Source categories do not match"); } return Inst.get(l.source).product(l, r); } if (FinCat.FinCat.equals(l.target) && FinCat.FinCat.equals(r.target)) { if (!l.source.equals(r.source)) { throw new RuntimeException("Source categories do not match"); } return FunCat.get(l.source).product(l, r); } return FinCat.FinCat.pair(l, r); }
@Override public Functor visit(FQLProgram env, FunctorExp.Exp e) { Functor l = e.l.accept(env, this); Functor r = e.r.accept(env, this); if (FinSet.FinSet.equals(l.target) && FinSet.FinSet.equals(r.target)) { if (!l.source.equals(r.source)) { throw new RuntimeException("Source categories do not match"); } return Inst.get(l.source).exp(l, r); } if (FinCat.FinCat.equals(l.target) && FinCat.FinCat.equals(r.target)) { if (!l.source.equals(r.source)) { throw new RuntimeException("Source categories do not match"); } throw new RuntimeException("Not implemented yet"); // TODO // return FunCat.get(l.source).product(l, r); } throw new RuntimeException("Cannot exponentiate " + l + " and " + r); }