class SFRP::Poly::FuncTyping

Attributes

body[R]
params[R]

Public Class Methods

new(param_size, &block) click to toggle source
# File lib/sfrp/poly/typing.rb, line 99
def initialize(param_size, &block)
  @params = Array.new(param_size) { Typing.new }
  @body = Typing.new
  block.call(self) if block
end

Public Instance Methods

instance(&block) click to toggle source
# File lib/sfrp/poly/typing.rb, line 118
def instance(&block)
  instance = to_ftype_annot.to_ftyping
  block.call(instance) if block
  instance
end
mono?() click to toggle source
# File lib/sfrp/poly/typing.rb, line 129
def mono?
  [@body, *@params].all?(&:mono?)
end
to_ftype_annot() click to toggle source
# File lib/sfrp/poly/typing.rb, line 105
def to_ftype_annot
  vars = @body.variables + @params.flat_map(&:variables)
  args = @params.map { |t| t.to_type_annot(vars) }
  FuncTypeAnnotation.new(@body.to_type_annot(vars), args)
end
to_s() click to toggle source
# File lib/sfrp/poly/typing.rb, line 133
def to_s
  to_ftype_annot.to_s
end
unify(other) click to toggle source
# File lib/sfrp/poly/typing.rb, line 111
def unify(other)
  raise unless @params.size == other.params.size
  @params.zip(other.params) { |a, b| a.unify(b) }
  @body.unify(other.body)
  self
end
unique_str() click to toggle source
# File lib/sfrp/poly/typing.rb, line 124
def unique_str
  args = @params + [@body]
  "Func#{@params.size}[#{args.map(&:unique_str).join(', ')}]"
end