Beispiel #1
0
def resolve(ctx, ty):

    # parameterized type
    if isinstance(ty, N.pt):
        con = resolve(ctx, ty.con)
        args = map(partial(resolve, ctx), ty.args)
        return N.pt(con, args)

    # function type
    elif isinstance(ty, N.fn):
        dom = resolve(ctx, ty.dom)
        cod = resolve(ctx, ty.cod)
        return N.fn(dom, cod)

    # uncurried domain, ick
    elif isinstance(ty, (list, tuple)):
        return map(partial(resolve, ctx), ty)

    # type variables
    else:
        # Either a named constant or a polymorphic type variable
        return ctx.get(ty, N.pv(ty))
Beispiel #2
0
def p_sig6(p):
    "sig : sig ARROW sig "
    p[0] = N.fn(p[1], p[3])
Beispiel #3
0
def p_sig6(p):
    "sig : sig ARROW sig "
    p[0] = N.fn(p[1], p[3])