示例#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))
示例#2
0
def p_sig9(p):
    'sig : NAME NAME'
    p[0] = N.pt(p[1], [p[2]])
示例#3
0
def p_sig8(p):
    'sig : NAME NAME NAME'
    p[0] = N.pt(p[1], [p[2], p[3]])
示例#4
0
def p_sig9(p):
    'sig : NAME NAME'
    p[0] = N.pt(p[1], [p[2]])
示例#5
0
def p_sig8(p):
    'sig : NAME NAME NAME'
    p[0] = N.pt(p[1], [p[2], p[3]])