Sha256: e52b27de689e6546018d6bfd97c3d11b9221b728f28ee8f9e0bdbb230f57b47f

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

module Finitio
  #
  # An AnyType generator allows capuring the set of every ruby citizen as a
  # Finitio type.
  #
  #     Any := .
  #
  # Object is used as concrete representation of the information type as the
  # Ruby `Object` class already captures everything.
  #
  #     R(.) = Object
  #
  # Accordingly, the `dress` transformation function has the signature below.
  # Note that dress always succeeds and returns its first argument.
  #
  #     dress :: Alpha  -> Object throws TypeError
  #     dress :: Object -> Object throws TypeError
  #
  class AnyType < Type

    def initialize(name = nil)
      super(name)
    end

    def default_name
      "Any"
    end

    def include?(value)
      true
    end

    def dress(value, handler = nil)
      value
    end

    def ==(other)
      other.is_a?(AnyType)
    end
    alias :eql? :==

    def hash
      self.class.hash ^ 37
    end

  end # class AnyType
end # module Finitio

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 lib/finitio/type/any_type.rb
finitio-0.4.0 lib/finitio/type/any_type.rb