Class: Algebrick::Type
Overview
Any Algebraic type defined by Algebrick is kind of Type
Instance Method Summary
collapse
Methods included from Reclude
#include, #included
#!, #&, #>, #>>, #case, #|, #~
Methods included from Matching
#any, #match?, #on
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Constructor Details
#initialize(name, &definition) ⇒ Type
Returns a new instance of Type.
23
24
25
26
|
# File 'lib/algebrick/type.rb', line 23
def initialize(name, &definition)
super &definition
@name = name
end
|
Instance Method Details
#==(other) ⇒ Object
36
37
38
|
# File 'lib/algebrick/type.rb', line 36
def ==(other)
raise NotImplementedError
end
|
#be_kind_of(type) ⇒ Object
40
41
42
|
# File 'lib/algebrick/type.rb', line 40
def be_kind_of(type)
raise NotImplementedError
end
|
48
49
50
|
# File 'lib/algebrick/type.rb', line 48
def inspect
to_s
end
|
#match(value, *cases) ⇒ Object
52
53
54
55
|
# File 'lib/algebrick/type.rb', line 52
def match(value, *cases)
Type! value, self
super value, *cases
end
|
28
29
30
|
# File 'lib/algebrick/type.rb', line 28
def name
super || @name || nil
end
|
#to_m(*args) ⇒ Object
32
33
34
|
# File 'lib/algebrick/type.rb', line 32
def to_m(*args)
raise NotImplementedError
end
|
44
45
46
|
# File 'lib/algebrick/type.rb', line 44
def to_s
raise NotImplementedError
end
|