class SFRP::Poly::Pattern

Public Class Methods

new(vconst_str, ref_var_str, patterns, id = nil) click to toggle source
# File lib/sfrp/poly/expression.rb, line 131
def initialize(vconst_str, ref_var_str, patterns, id = nil)
  @vconst_str = vconst_str
  @ref_var_str = ref_var_str
  @patterns = patterns
  @id = id
end

Public Instance Methods

clone() click to toggle source
# File lib/sfrp/poly/expression.rb, line 153
def clone
  Pattern.new(@vconst_str, @ref_var_str, @patterns.map(&:clone), @id)
end
to_mono(monofier) click to toggle source
# File lib/sfrp/poly/expression.rb, line 157
def to_mono(monofier)
  raise UndeterminableTypeError.new(@id, @typing) unless @typing.mono?
  mono_type_str = monofier.use_type(@typing)
  if @vconst_str
    mono_vconst_str = monofier.use_vconst(@vconst_str, @typing)
    ch = @patterns.map { |pat| pat.to_mono(monofier) }
    M.pref(mono_type_str, mono_vconst_str, @ref_var_str, *ch)
  else
    M.pany(mono_type_str, @ref_var_str)
  end
end
typing(set, var_env) click to toggle source
# File lib/sfrp/poly/expression.rb, line 138
def typing(set, var_env)
  raise if @typing
  @typing = Typing.new do |t|
    var_env[@ref_var_str] = t if @ref_var_str
    if @vconst_str
      set.vconst(@vconst_str).ftyping.instance do |ft|
        @patterns.zip(ft.params) do |pat, param_typing|
          pat.typing(set, var_env).unify(param_typing)
        end
        ft.body.unify(t)
      end
    end
  end
end