class Dhall::TypeChecker::Context
Public Class Methods
new(bindings=Hash.new([]))
click to toggle source
# File lib/dhall/typecheck.rb, line 55 def initialize(bindings=Hash.new([])) @bindings = bindings.freeze freeze end
Public Instance Methods
add(ftype)
click to toggle source
# File lib/dhall/typecheck.rb, line 65 def add(ftype) self.class.new(@bindings.merge( ftype.var => [ftype.type] + @bindings[ftype.var] )).shift(1, ftype.var, 0) end
fetch(var)
click to toggle source
# File lib/dhall/typecheck.rb, line 60 def fetch(var) @bindings[var.name][var.index] || (raise TypeError, "Free variable: #{var}") end
shift(amount, name, min_index)
click to toggle source
# File lib/dhall/typecheck.rb, line 71 def shift(amount, name, min_index) self.class.new(@bindings.merge( Hash[@bindings.map do |var, bindings| [var, bindings.map { |b| b.shift(amount, name, min_index) }] end] )) end