Module: Jade::Type
- Extended by:
- Type
- Included in:
- Parsing, Type
- Defined in:
- lib/jade/type.rb,
lib/jade/type/var.rb,
lib/jade/type/base.rb,
lib/jade/type/unit.rb,
lib/jade/type/function.rb,
lib/jade/type/constraint.rb,
lib/jade/type/application.rb,
lib/jade/type/constructor.rb,
lib/jade/type/anonymous_record.rb,
lib/jade/type/partial_application.rb
Defined Under Namespace
Modules: Base
Classes: AnonymousRecord, Application, Constraint, Constructor, Function, PartialApplication, Unit, Var
Constant Summary
collapse
- CONSTRUCTORS =
{}
Instance Method Summary
collapse
Instance Method Details
#anonymous_record(fields, row_var) ⇒ Object
63
64
65
|
# File 'lib/jade/type.rb', line 63
def anonymous_record(fields, row_var)
AnonymousRecord[fields, row_var]
end
|
#bool ⇒ Object
40
41
42
|
# File 'lib/jade/type.rb', line 40
def bool
constructor('Basics.Bool').apply([])
end
|
#constraint(interface_id, type, origin, index: :unindex) ⇒ Object
67
68
69
70
|
# File 'lib/jade/type.rb', line 67
def constraint(interface_id, type, origin, index: :unindex)
fail unless interface_id in String
Constraint[interface_id, type, origin, index]
end
|
#constructor(name) ⇒ Object
50
51
52
|
# File 'lib/jade/type.rb', line 50
def constructor(name)
CONSTRUCTORS[name] ||= Constructor[name].freeze
end
|
#float ⇒ Object
32
33
34
|
# File 'lib/jade/type.rb', line 32
def float
constructor('Basics.Float').apply([])
end
|
#from_symbol(symbol, registry, var_gen) ⇒ Object
15
16
17
18
|
# File 'lib/jade/type.rb', line 15
def from_symbol(symbol, registry, var_gen)
from_symbol_r(symbol, registry, var_gen, {})
.then { |type, constraints, _| [type, constraints] }
end
|
#function(args, return_type) ⇒ Object
54
55
56
|
# File 'lib/jade/type.rb', line 54
def function(args, return_type)
Function[args, return_type]
end
|
#int ⇒ Object
24
25
26
|
# File 'lib/jade/type.rb', line 24
def int
constructor('Basics.Int').apply([])
end
|
#list ⇒ Object
44
45
46
|
# File 'lib/jade/type.rb', line 44
def list
constructor('List.List')
end
|
#signature(fn_type) ⇒ Object
58
59
60
61
|
# File 'lib/jade/type.rb', line 58
def signature(fn_type)
fn_type => Function(args:, return_type:)
[args, return_type]
end
|
#string ⇒ Object
36
37
38
|
# File 'lib/jade/type.rb', line 36
def string
constructor('String.String').apply([])
end
|
#unit ⇒ Object
28
29
30
|
# File 'lib/jade/type.rb', line 28
def unit
constructor('Basics.Unit').apply([])
end
|
#var(id, name = nil) ⇒ Object
20
21
22
|
# File 'lib/jade/type.rb', line 20
def var(id, name = nil)
Var[id, name]
end
|