Sha256: 4a1477a629daf7aa673efeff07fa7c4578110278dcc73ddf37d29dc9de00d874
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Furnace class Type::Variable def initialize freeze end def to_type self end def subtype_of?(other) other.instance_of?(Type::Top) || self == other end def supertype_of?(other) other.subtype_of?(self) end def variable? true end def replace_type_with(type, replacement) if self == type replacement.to_type else self end end def specialize(other) { self => other } end def awesome_print(p=AwesomePrinter.new) p.type_variable self end end class Type::Variable::Annotator def initialize @last_annotation = "a" @annotations = Hash.new do |hash, var| unless var.is_a? Type::Variable raise ArgumentError, "#{self.class} cannot annotate #{var.class}" end annotation = @last_annotation @last_annotation = @last_annotation.succ hash[var] = annotation end end def annotate(var) @annotations[var] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
furnace-0.4.0.beta.2 | lib/furnace/type/variable.rb |