Search in sources :

Example 1 with Colim

use of catdata.fqlpp.CatExp.Colim in project fql by CategoricalData.

the class PPParser method toCat.

private static CatExp toCat(Object o) {
    if (o.toString().equals("Set")) {
        return new Named("Set");
    }
    if (o.toString().equals("Cat")) {
        return new Named("Cat");
    }
    if (o instanceof Tuple4) {
        Tuple4 t = (Tuple4) o;
        return new Kleisli(t.b.toString(), t.c.toString(), t.d.toString(), t.a.toString().equals("cokleisli"));
    }
    try {
        Tuple3<?, ?, ?> t = (Tuple3<?, ?, ?>) o;
        String y = t.b.toString();
        if (y.equals("+")) {
            return new Plus(toCat(t.a), toCat(t.c));
        } else if (y.equals("*")) {
            return new Times(toCat(t.a), toCat(t.c));
        } else if (y.equals("^")) {
            return new CatExp.Exp(toCat(t.a), toCat(t.c));
        } else if (t.a.toString().equals("union")) {
            return new Union(toCat(t.b), toCat(t.c));
        } else {
            return toCatConst(o);
        }
    } catch (RuntimeException cce) {
    }
    try {
        org.jparsec.functors.Pair<?, ?> p = (org.jparsec.functors.Pair<?, ?>) o;
        if (p.a.toString().equals("dom")) {
            return new CatExp.Dom(toFtr(p.b));
        } else if (p.a.toString().equals("cod")) {
            return new Cod(toFtr(p.b));
        } else if (p.a.toString().equals("colim")) {
            return new Colim((String) p.b);
        }
    } catch (RuntimeException cce) {
    }
    try {
        if (o.toString().equals("void")) {
            return new CatExp.Zero();
        } else if (o.toString().equals("unit")) {
            return new CatExp.One();
        }
    } catch (RuntimeException cce) {
    }
    return new CatExp.Var(o.toString());
}
Also used : Colim(catdata.fqlpp.CatExp.Colim) Named(catdata.fqlpp.CatExp.Named) Zero(catdata.fqlpp.FunctorExp.Zero) Dom(catdata.fqlpp.FunctorExp.Dom) Var(catdata.fqlpp.FunctorExp.Var) Union(catdata.fqlpp.CatExp.Union) Tuple4(org.jparsec.functors.Tuple4) Kleisli(catdata.fqlpp.CatExp.Kleisli) Tuple3(org.jparsec.functors.Tuple3) Times(catdata.fqlpp.CatExp.Times) Cod(catdata.fqlpp.CatExp.Cod) Plus(catdata.fqlpp.CatExp.Plus) Exp(catdata.fqlpp.FunctorExp.Exp) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)1 Cod (catdata.fqlpp.CatExp.Cod)1 Colim (catdata.fqlpp.CatExp.Colim)1 Kleisli (catdata.fqlpp.CatExp.Kleisli)1 Named (catdata.fqlpp.CatExp.Named)1 Plus (catdata.fqlpp.CatExp.Plus)1 Times (catdata.fqlpp.CatExp.Times)1 Union (catdata.fqlpp.CatExp.Union)1 Dom (catdata.fqlpp.FunctorExp.Dom)1 Exp (catdata.fqlpp.FunctorExp.Exp)1 Var (catdata.fqlpp.FunctorExp.Var)1 Zero (catdata.fqlpp.FunctorExp.Zero)1 Tuple3 (org.jparsec.functors.Tuple3)1 Tuple4 (org.jparsec.functors.Tuple4)1