Class: Dhallish::Types::Function
- Inherits:
-
Object
- Object
- Dhallish::Types::Function
- Defined in:
- lib/types.rb
Instance Attribute Summary collapse
-
#argtype ⇒ Object
Type of Function that takes argtype and returns restype.
-
#restype ⇒ Object
Returns the value of attribute restype.
-
#unres ⇒ Object
Returns the value of attribute unres.
Instance Method Summary collapse
- #==(otype) ⇒ Object
-
#initialize(argtype, restype, unres = nil) ⇒ Function
constructor
A new instance of Function.
- #to_s ⇒ Object
Constructor Details
#initialize(argtype, restype, unres = nil) ⇒ Function
Returns a new instance of Function.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# 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 |
Instance Attribute Details
#argtype ⇒ Object
Type of Function that takes argtype and returns restype
82 83 84 |
# File 'lib/types.rb', line 82 def argtype @argtype end |
#restype ⇒ Object
Returns the value of attribute restype.
83 84 85 |
# File 'lib/types.rb', line 83 def restype @restype end |
#unres ⇒ Object
Returns the value of attribute unres.
84 85 86 |
# File 'lib/types.rb', line 84 def unres @unres end |
Instance Method Details
#==(otype) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# 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 ⇒ Object
110 111 112 113 114 115 116 117 118 |
# 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 |