Search in sources :

Example 1 with AqlJs

use of catdata.aql.AqlJs 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

Chc (catdata.Chc)1 Ctx (catdata.Ctx)1 Pair (catdata.Pair)1 Triple (catdata.Triple)1 Util (catdata.Util)1 AqlJs (catdata.aql.AqlJs)1 AqlOptions (catdata.aql.AqlOptions)1 Collage (catdata.aql.Collage)1 Eq (catdata.aql.Eq)1 Kind (catdata.aql.Kind)1 RawTerm (catdata.aql.RawTerm)1 Term (catdata.aql.Term)1 TypeSide (catdata.aql.TypeSide)1 Var (catdata.aql.Var)1 En (catdata.aql.exp.SchExpRaw.En)1 Sym (catdata.aql.exp.TyExpRaw.Sym)1 Ty (catdata.aql.exp.TyExpRaw.Ty)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1