class Dhallish::Types::Function

Attributes

argtype[RW]

Type of Function that takes argtype and returns restype

restype[RW]
unres[RW]

Public Class Methods

new(argtype, restype, unres=nil) click to toggle source
# File lib/types.rb, line 86
def initialize(argtype, restype, unres=nil)
        @argtype = argtype
        @restype = restype
        if !unres.nil?
                if !unres.is_a? Symbol
                        @unres = unres.to_sym
                else
                        @unres = unres
                end
        else
                @unres = nil
        end
end

Public Instance Methods

==(otype) click to toggle source
# File lib/types.rb, line 100
def ==(otype)
        if !(otype.is_a? Function) or !(otype.argtype == @argtype)
                false
        elsif !@restype.nil? and !otype.restype.nil?
                @restype == otype.restype
        else
                true
        end
end
to_s() click to toggle source
# File lib/types.rb, line 110
def to_s()
        if !@restype.nil? and !@unres.nil?
                "∀(#{@unres}: #{@argtype.to_s}) -> #{@restype.to_s}"
        elsif !@restype.nil?
                "∀(#{@argtype.to_s}) -> #{@restype.to_s}"
        else
                "∀(#{@argtype.to_s}) -> ?"
        end
end