Module: Jade::Frontend::TypeChecking::Generalization

Extended by:
Generalization
Included in:
Generalization
Defined in:
lib/jade/frontend/type_checking/generalization.rb

Instance Method Summary collapse

Instance Method Details

#generalize(env, type, constraints = []) ⇒ Object



7
8
9
10
11
12
# File 'lib/jade/frontend/type_checking/generalization.rb', line 7

def generalize(env, type, constraints = [])
  (type.unbound_vars + constraints.flat_map(&:unbound_vars))
    .uniq(&:id)
    .then { it - env.free_vars }
    .then { Scheme[it, type, constraints] }
end