Class: Algebrick::Type
- Inherits:
-
Module
show all
- Includes:
- MatcherDelegations, Matching, Reclude, TypeCheck
- Defined in:
- lib/algebrick/type.rb
Overview
Any Algebraic type defined by Algebrick is kind of Type
Instance Method Summary
(collapse)
Methods included from Reclude
#include, #included, #included_into
#!, #&, #>, #>>, #case, #|, #~
Methods included from Matching
#any, match_value, #on
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?, error
Constructor Details
- (Type) initialize(name, &definition)
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
- (Object) ==(other)
36
37
38
|
# File 'lib/algebrick/type.rb', line 36
def ==(other)
raise NotImplementedError
end
|
- (Object) be_kind_of(type)
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
|
- (Object) match(value, *cases)
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 || 'NoName'
end
|
- (Object) to_m(*args)
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
|