Beispiel #1
0
 def instantiate(tcon, t):
     "Instantiate Polytypes as Monotypes with fresh type variables"
     if isinstance(t, T.Polytype):
         vars = tcon.fresh_typelist(t.variables)
         return T.substituted_type(t.monotype(), dict(zip(t.variables, vars)))
     else:
         return t
 def instantiate(tcon, t):
     'Instantiate Polytypes as Monotypes with fresh type variables'
     if isinstance(t, T.Polytype):
         vars = tcon.fresh_typelist(t.variables)
         return T.substituted_type(t.monotype(),
                                   dict(zip(t.variables, vars)))
     else:
         return t
Beispiel #3
0
def resolve_type(t, tcon):
    """
    Return a new type where all type variables occurring free in T and
    bound in the given context are resolved to their bound values.
    """

    free = list(T.free_in_type(t))
    if not free:  return t

    R = resolution_map(free, tcon.environment)
    for v in free:
        if R[v] != v:
            R[v] = resolve_type(R[v], tcon)

    return T.substituted_type(t, R)
def resolve_type(t, S):
    """
    Return a new type where all type variables occurring free in t
    are replaced with their values under the substitution S.  If t has
    no free variables, it is returned unchanged.
    """

    free = list(T.free_in_type(t))
    if not free: return t

    R = resolution_map(free, S)
    for v in free:
        if R[v] != v:
            R[v] = resolve_type(R[v], S)

    return T.substituted_type(t, R)
def resolve_type(t, S):
    """
    Return a new type where all type variables occurring free in t
    are replaced with their values under the substitution S.  If t has
    no free variables, it is returned unchanged.
    """
    
    free = list(T.free_in_type(t))
    if not free:  return t

    R = resolution_map(free, S)
    for v in free:
        if R[v] != v:
            R[v] = resolve_type(R[v], S)

    return T.substituted_type(t, R)