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