Module: Jade::Frontend::TypeChecking::Instantiation
- Extended by:
- Instantiation
- Included in:
- Instantiation
- Defined in:
- lib/jade/frontend/type_checking/instantiation.rb
Instance Method Summary collapse
-
#instantiate(scheme, var_gen) ⇒ Object
Index = position in scheme.constraints.
Instance Method Details
#instantiate(scheme, var_gen) ⇒ Object
Index = position in scheme.constraints. Lets attach_dictionary write positionally so sibling same-iface markers don’t collide on one origin.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jade/frontend/type_checking/instantiation.rb', line 9 def instantiate(scheme, var_gen) sub = scheme .quantified.reduce(Substitution::EMPTY) do |subs, var| subs.bind(var.id, var_gen.fresh(var.name)) end scheme .constraints .each_with_index .map { |c, i| sub.apply(c.with(index: i)) } .then { [sub.apply(scheme.type), it] } end |