Search in sources :

Example 31 with Ctx

use of catdata.Ctx in project fql by CategoricalData.

the class TyExpRaw method eval.

@Override
public synchronized TypeSide<Ty, Sym> eval(AqlEnv env) {
    AqlOptions ops = new AqlOptions(options, col, env.defaults);
    // changed my mind: do not defer equation checking since invokes javascript
    // col.
    AqlJs<Ty, Sym> js = new AqlJs<>(col.syms, col.java_tys, col.java_parsers, col.java_fns);
    for (Triple<List<Pair<String, String>>, RawTerm, RawTerm> eq : eqs) {
        try {
            Triple<Ctx<Var, Chc<Ty, Void>>, Term<Ty, Void, Sym, Void, Void, Void, Void>, Term<Ty, Void, Sym, Void, Void, Void, Void>> tr = infer1x(yyy(eq.first), eq.second, eq.third, null, col, "", js);
            col.eqs.add(new Eq<>(tr.first, tr.second, tr.third));
        } catch (RuntimeException ex) {
            ex.printStackTrace();
            throw new LocException(find("equations", eq), "In equation " + eq.second + " = " + eq.third + ", " + ex.getMessage());
        }
    }
    for (Pair<Integer, TyExp<Ty, Sym>> k : imports) {
        TypeSide<Ty, Sym> v = k.second.eval(env);
        col.addAll(v.collage());
    }
    Set<Triple<Ctx<Var, Ty>, Term<Ty, Void, Sym, Void, Void, Void, Void>, Term<Ty, Void, Sym, Void, Void, Void, Void>>> eqs0 = col.eqsAsTriples().stream().map(x -> new Triple<>(xxx(x.first), x.second, x.third)).collect(Collectors.toSet());
    TypeSide<Ty, Sym> ret = new TypeSide<Ty, Sym>(col.tys, col.syms.map, eqs0, col.java_tys.map, col.java_parsers.map, col.java_fns.map, ops);
    return ret;
}
Also used : AqlOptions(catdata.aql.AqlOptions) Ctx(catdata.Ctx) TypeSide(catdata.aql.TypeSide) RawTerm(catdata.aql.RawTerm) En(catdata.aql.exp.SchExpRaw.En) Sym(catdata.aql.exp.TyExpRaw.Sym) Chc(catdata.Chc) HashMap(java.util.HashMap) Function(java.util.function.Function) HashSet(java.util.HashSet) Map(java.util.Map) AqlJs(catdata.aql.AqlJs) Collage(catdata.aql.Collage) Eq(catdata.aql.Eq) Term(catdata.aql.Term) LinkedList(java.util.LinkedList) Pair(catdata.Pair) Collection(java.util.Collection) Kind(catdata.aql.Kind) Util(catdata.Util) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Var(catdata.aql.Var) Entry(java.util.Map.Entry) Triple(catdata.Triple) Ty(catdata.aql.exp.TyExpRaw.Ty) Ctx(catdata.Ctx) Var(catdata.aql.Var) AqlJs(catdata.aql.AqlJs) LinkedList(java.util.LinkedList) List(java.util.List) TypeSide(catdata.aql.TypeSide) Ty(catdata.aql.exp.TyExpRaw.Ty) Sym(catdata.aql.exp.TyExpRaw.Sym) RawTerm(catdata.aql.RawTerm) Term(catdata.aql.Term) RawTerm(catdata.aql.RawTerm) Triple(catdata.Triple) AqlOptions(catdata.aql.AqlOptions)

Aggregations

Ctx (catdata.Ctx)31 Ty (catdata.aql.exp.TyExpRaw.Ty)27 En (catdata.aql.exp.SchExpRaw.En)26 Sym (catdata.aql.exp.TyExpRaw.Sym)25 Att (catdata.aql.exp.SchExpRaw.Att)24 Fk (catdata.aql.exp.SchExpRaw.Fk)24 Pair (catdata.Pair)22 Chc (catdata.Chc)19 HashSet (java.util.HashSet)19 Triple (catdata.Triple)17 Gen (catdata.aql.exp.InstExpRaw.Gen)16 HashMap (java.util.HashMap)15 AqlOptions (catdata.aql.AqlOptions)14 List (java.util.List)14 Term (catdata.aql.Term)13 Sk (catdata.aql.exp.InstExpRaw.Sk)13 Collage (catdata.aql.Collage)12 RawTerm (catdata.aql.RawTerm)11 LinkedList (java.util.LinkedList)10 Var (catdata.aql.Var)9