Sha256: a47dc7663c93253983c84a164fa3ce28c0315112225b35076937d492e80c9fe8

Contents?: true

Size: 891 Bytes

Versions: 7

Compression:

Stored size: 891 Bytes

Contents

module Finitio
  class HighOrderType < Type

    def initialize(vars, defn, name = nil, metadata = nil)
      super(name, metadata)
      @vars = vars
      @defn = defn
    end
    attr_reader :vars, :defn

    def default_name
      "Type<#{vars.join(',')}>"
    end

    def suppremum(other)
      raise NotImplementedError, "Suppremum is not defined on high order types"
    end

    def ==(other)
      super || other.is_a?(HighOrderType) \
            && other.vars == self.vars \
            && other.defn = self.defn
    end

    def resolve_proxies(system)
      self
    end

    def instantiate(compilation, sub_types)
      overrides = Hash[vars.zip(sub_types)]
      defn.resolve_proxies(compilation.with_scope(overrides))
    end

    def unconstrained
      HighOrderType.new(vars, defn.unconstrained, name, metadata)
    end

  end # class HighOrderType
end # module Finitio

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finitio-0.11.3 lib/finitio/type/high_order_type.rb
finitio-0.11.2 lib/finitio/type/high_order_type.rb
finitio-0.11.1 lib/finitio/type/high_order_type.rb
finitio-0.10.0 lib/finitio/type/high_order_type.rb
finitio-0.9.1 lib/finitio/type/high_order_type.rb
finitio-0.9.0 lib/finitio/type/high_order_type.rb
finitio-0.8.0 lib/finitio/type/high_order_type.rb