class SFRP::Poly::FuncTypeAnnotation

Public Class Methods

new(ret_type_annot, arg_type_annots) click to toggle source
# File lib/sfrp/poly/typing.rb, line 139
def initialize(ret_type_annot, arg_type_annots)
  @ret_type_annot = ret_type_annot
  @arg_type_annots = arg_type_annots
end

Public Instance Methods

to_ftyping(var_strs = nil) click to toggle source
# File lib/sfrp/poly/typing.rb, line 144
def to_ftyping(var_strs = nil)
  var_strs ||= [@ret_type_annot, *@arg_type_annots].flat_map(&:var_strs)
  tbl = Hash[var_strs.uniq.map { |s| [s, Typing.new] }]
  FuncTyping.new(@arg_type_annots.size) do |ft|
    ft.params.zip(@arg_type_annots) { |t, at| t.unify(at.to_typing(tbl)) }
    ft.body.unify(@ret_type_annot.to_typing(tbl))
  end
end
to_s() click to toggle source
# File lib/sfrp/poly/typing.rb, line 153
def to_s
  "(#{@arg_type_annots.map(&:to_s).join(', ')}) -> #{@ret_type_annot}"
end