Search in sources :

Example 1 with Times

use of catdata.fql.decl.SigExp.Times in project fql by CategoricalData.

the class MapExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Prod e) {
    List<String> l = new LinkedList<>(seen);
    Pair<SigExp, SigExp> lt = e.l.accept(env, this);
    seen = l;
    Pair<SigExp, SigExp> rt = e.r.accept(env, this);
    seen = l;
    if (!lt.first.equals(rt.first)) {
        throw new RuntimeException("source schema mismatch on " + e + ": " + lt.first + " and " + rt.first);
    }
    return new Pair<>(lt.first, new Times(lt.second, rt.second));
}
Also used : Times(catdata.fql.decl.SigExp.Times) LinkedList(java.util.LinkedList) Pair(catdata.Pair)

Example 2 with Times

use of catdata.fql.decl.SigExp.Times in project fql by CategoricalData.

the class MapExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Dist1 e) {
    SigExp aa = e.a.typeOf(env);
    SigExp bb = e.b.typeOf(env);
    SigExp cc = e.c.typeOf(env);
    return new Pair<>(new Times(aa, new Plus(bb, cc)), new Plus(new Times(aa, bb), new Times(aa, cc)));
}
Also used : Times(catdata.fql.decl.SigExp.Times) Plus(catdata.fql.decl.SigExp.Plus) Pair(catdata.Pair)

Example 3 with Times

use of catdata.fql.decl.SigExp.Times in project fql by CategoricalData.

the class MapExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Fst e) {
    SigExp a = e.s.typeOf(env);
    SigExp b = e.t.typeOf(env);
    return new Pair<>(new Times(a, b), a);
}
Also used : Times(catdata.fql.decl.SigExp.Times) Pair(catdata.Pair)

Example 4 with Times

use of catdata.fql.decl.SigExp.Times in project fql by CategoricalData.

the class MapExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Curry e) {
    Pair<SigExp, SigExp> ft = e.f.accept(env, this);
    if (!(ft.first instanceof Times)) {
        throw new RuntimeException("Not a product: " + ft.first + " in " + e);
    }
    Times t = (Times) ft.first;
    return new Pair<>(t.a, new Exp(ft.second, t.b));
}
Also used : Times(catdata.fql.decl.SigExp.Times) Exp(catdata.fql.decl.SigExp.Exp) Pair(catdata.Pair)

Example 5 with Times

use of catdata.fql.decl.SigExp.Times in project fql by CategoricalData.

the class MapExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Apply e) {
    SigExp s = e.s.typeOf(env);
    SigExp t = e.t.typeOf(env);
    return new Pair<>(new Times(new Exp(s, t), t), s);
}
Also used : Times(catdata.fql.decl.SigExp.Times) Exp(catdata.fql.decl.SigExp.Exp) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)8 Times (catdata.fql.decl.SigExp.Times)8 Exp (catdata.fql.decl.SigExp.Exp)2 Plus (catdata.fql.decl.SigExp.Plus)2 LinkedList (java.util.LinkedList)2 Quad (catdata.Quad)1 Triple (catdata.Triple)1 FQLException (catdata.fql.FQLException)1 Arr (catdata.fql.cat.Arr)1 Const (catdata.fql.decl.MapExp.Const)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1