示例#1
0
文件: CatOps.java 项目: epost/fql2
 @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);
 }
示例#2
0
文件: CatOps.java 项目: epost/fql2
 @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);
 }