jade-lang 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +439 -2
- data/docs/interop.md +18 -1
- data/docs/stdlib.md +3 -1
- data/docs/syntax.md +96 -0
- data/lib/jade/api.rb +9 -0
- data/lib/jade/ast.rb +37 -1
- data/lib/jade/cli/eject.rb +132 -0
- data/lib/jade/cli.rb +2 -0
- data/lib/jade/codegen/boundary/specialized/list.rb +11 -7
- data/lib/jade/codegen/boundary/specialized/maybe.rb +2 -2
- data/lib/jade/codegen/boundary/specialized/record.rb +19 -4
- data/lib/jade/codegen/boundary/specialized/scalar.rb +2 -2
- data/lib/jade/codegen/boundary/specialized.rb +13 -5
- data/lib/jade/codegen/boundary.rb +12 -2
- data/lib/jade/codegen/context.rb +17 -0
- data/lib/jade/codegen/error.rb +1 -0
- data/lib/jade/codegen/function_call.rb +23 -7
- data/lib/jade/codegen/function_declaration.rb +25 -13
- data/lib/jade/codegen/helpers.rb +27 -4
- data/lib/jade/codegen/implementation.rb +2 -2
- data/lib/jade/codegen/inline.rb +1 -1
- data/lib/jade/codegen/inlines.rb +6 -1
- data/lib/jade/codegen/names.rb +31 -0
- data/lib/jade/codegen/pattern/constructor.rb +2 -2
- data/lib/jade/codegen/transforms/fold_shape.rb +1 -1
- data/lib/jade/codegen.rb +76 -15
- data/lib/jade/compiler.rb +2 -0
- data/lib/jade/entry.rb +1 -1
- data/lib/jade/error.rb +5 -0
- data/lib/jade/extensions.rb +70 -0
- data/lib/jade/formatter/calls.rb +68 -11
- data/lib/jade/formatter/collections.rb +4 -4
- data/lib/jade/formatter/declarations.rb +13 -15
- data/lib/jade/formatter/helper.rb +20 -0
- data/lib/jade/formatter/infix_application.rb +19 -4
- data/lib/jade/formatter/lambda.rb +24 -12
- data/lib/jade/formatter/pattern.rb +3 -0
- data/lib/jade/frontend/desugaring/placeholder.rb +40 -17
- data/lib/jade/frontend/desugaring.rb +29 -9
- data/lib/jade/frontend/fixity_fixer.rb +6 -4
- data/lib/jade/frontend/forward_declaration/error/alias_expansion.rb +23 -0
- data/lib/jade/frontend/forward_declaration/error/duplicate_constructor_name.rb +45 -0
- data/lib/jade/frontend/forward_declaration/error/duplicate_type_name.rb +42 -0
- data/lib/jade/frontend/forward_declaration/error.rb +3 -0
- data/lib/jade/frontend/forward_declaration/helper.rb +58 -0
- data/lib/jade/frontend/forward_declaration/import_declaration.rb +4 -0
- data/lib/jade/frontend/forward_declaration/interface_declaration.rb +6 -0
- data/lib/jade/frontend/forward_declaration/module.rb +4 -0
- data/lib/jade/frontend/forward_declaration/struct_declaration.rb +10 -1
- data/lib/jade/frontend/forward_declaration/type_alias_declaration.rb +37 -0
- data/lib/jade/frontend/forward_declaration/type_declaration.rb +10 -1
- data/lib/jade/frontend/forward_declaration.rb +2 -0
- data/lib/jade/frontend/pattern_analysis/exhaustiveness.rb +47 -43
- data/lib/jade/frontend/pattern_analysis/matrix.rb +28 -219
- data/lib/jade/frontend/pattern_analysis/pattern.rb +132 -0
- data/lib/jade/frontend/pattern_analysis/redundancy.rb +24 -0
- data/lib/jade/frontend/pattern_analysis/signature.rb +220 -0
- data/lib/jade/frontend/pattern_analysis/usefulness.rb +72 -0
- data/lib/jade/frontend/pattern_analysis/witnesses.rb +73 -0
- data/lib/jade/frontend/pattern_analysis.rb +5 -38
- data/lib/jade/frontend/semantic_analysis/body.rb +29 -1
- data/lib/jade/frontend/semantic_analysis/error/duplicate_implementation.rb +39 -0
- data/lib/jade/frontend/semantic_analysis/error/implementation_on_alias.rb +24 -0
- data/lib/jade/frontend/semantic_analysis/error/no_base_case.rb +45 -0
- data/lib/jade/frontend/semantic_analysis/error/placeholder_not_allowed.rb +15 -3
- data/lib/jade/frontend/semantic_analysis/error/recursive_type_alias.rb +24 -0
- data/lib/jade/frontend/semantic_analysis/error.rb +4 -0
- data/lib/jade/frontend/semantic_analysis/helper.rb +41 -0
- data/lib/jade/frontend/semantic_analysis/implementation.rb +13 -10
- data/lib/jade/frontend/semantic_analysis/inhabitedness.rb +90 -0
- data/lib/jade/frontend/semantic_analysis/interop_import_declaration.rb +28 -16
- data/lib/jade/frontend/semantic_analysis/keyed_call.rb +21 -5
- data/lib/jade/frontend/semantic_analysis/pattern_range.rb +16 -0
- data/lib/jade/frontend/semantic_analysis/struct_declaration.rb +1 -0
- data/lib/jade/frontend/semantic_analysis/type_alias_declaration/cycle_detection.rb +95 -0
- data/lib/jade/frontend/semantic_analysis/type_alias_declaration.rb +48 -0
- data/lib/jade/frontend/semantic_analysis/type_declaration.rb +1 -0
- data/lib/jade/frontend/semantic_analysis.rb +5 -0
- data/lib/jade/frontend/type_checking/canonicalize.rb +1 -0
- data/lib/jade/frontend/type_checking/cascade.rb +90 -0
- data/lib/jade/frontend/type_checking/constraints/deriving/encodable.rb +10 -0
- data/lib/jade/frontend/type_checking/constraints/deriving.rb +5 -4
- data/lib/jade/frontend/type_checking/constraints.rb +18 -3
- data/lib/jade/frontend/type_checking/error/display.rb +49 -0
- data/lib/jade/frontend/type_checking/error/division_by_zero.rb +31 -0
- data/lib/jade/frontend/type_checking/error/empty_range_pattern.rb +25 -0
- data/lib/jade/frontend/type_checking/error/function_body_type_mismatch.rb +4 -3
- data/lib/jade/frontend/type_checking/error/function_call_type_mismatch.rb +108 -5
- data/lib/jade/frontend/type_checking/error/if_branch_type_mismatch.rb +1 -1
- data/lib/jade/frontend/type_checking/error/if_branches_type_mismatch.rb +1 -1
- data/lib/jade/frontend/type_checking/error/if_condition_type_mismatch.rb +1 -1
- data/lib/jade/frontend/type_checking/error/implementation_type_mismatch.rb +1 -1
- data/lib/jade/frontend/type_checking/error/list_item_type_mismatch.rb +1 -1
- data/lib/jade/frontend/type_checking/error/missing_patterns.rb +20 -4
- data/lib/jade/frontend/type_checking/error/pattern_type_mismatch.rb +7 -1
- data/lib/jade/frontend/type_checking/error/range_pattern_type.rb +29 -0
- data/lib/jade/frontend/type_checking/error/record_access_type_mismatch.rb +2 -2
- data/lib/jade/frontend/type_checking/error/recursive_derivation.rb +25 -0
- data/lib/jade/frontend/type_checking/error/type_mismatch.rb +10 -2
- data/lib/jade/frontend/type_checking/error/unreachable_branch.rb +22 -0
- data/lib/jade/frontend/type_checking/error.rb +6 -0
- data/lib/jade/frontend/type_checking/inference/assign.rb +1 -1
- data/lib/jade/frontend/type_checking/inference/case_of.rb +21 -4
- data/lib/jade/frontend/type_checking/inference/division.rb +50 -0
- data/lib/jade/frontend/type_checking/inference/function_call.rb +47 -2
- data/lib/jade/frontend/type_checking/inference/lambda.rb +1 -1
- data/lib/jade/frontend/type_checking/inference/pattern.rb +35 -0
- data/lib/jade/frontend/type_checking/inference/type_alias_declaration.rb +18 -0
- data/lib/jade/frontend/type_checking/inference.rb +2 -0
- data/lib/jade/frontend/type_checking/loader.rb +11 -0
- data/lib/jade/frontend/type_checking/port_resolution.rb +26 -8
- data/lib/jade/frontend/type_checking/substitution.rb +2 -2
- data/lib/jade/frontend/type_checking.rb +3 -1
- data/lib/jade/frontend/usage_analysis.rb +5 -1
- data/lib/jade/interop/boundary.rb +64 -24
- data/lib/jade/interop/error.rb +35 -7
- data/lib/jade/interop/lowering.rb +8 -2
- data/lib/jade/lsp/converters.rb +83 -2
- data/lib/jade/lsp/handlers.rb +122 -25
- data/lib/jade/lsp/snippets.rb +12 -0
- data/lib/jade/lsp/state.rb +11 -4
- data/lib/jade/module_loader/build.rb +36 -0
- data/lib/jade/module_loader.rb +1 -0
- data/lib/jade/parsing/combinators.rb +78 -2
- data/lib/jade/parsing/error.rb +43 -6
- data/lib/jade/parsing/type.rb +5 -3
- data/lib/jade/parsing.rb +140 -26
- data/lib/jade/runtime.rb +32 -13
- data/lib/jade/source.rb +6 -2
- data/lib/jade/stdlib/basics.rb +22 -3
- data/lib/jade/stdlib/char.rb +2 -0
- data/lib/jade/stdlib/clock.rb +6 -2
- data/lib/jade/stdlib/decimal.rb +51 -14
- data/lib/jade/stdlib/intrinsics.rb +59 -6
- data/lib/jade/stdlib/list.rb +37 -1
- data/lib/jade/stdlib/number.rb +47 -0
- data/lib/jade/stdlib/range.rb +211 -0
- data/lib/jade/stdlib.rb +11 -4
- data/lib/jade/symbol/alias.rb +11 -0
- data/lib/jade/symbol/parser.rb +1 -1
- data/lib/jade/symbol.rb +13 -1
- data/lib/jade/task.rb +74 -56
- data/lib/jade/type/anonymous_record.rb +11 -2
- data/lib/jade/type/application.rb +11 -2
- data/lib/jade/type/base.rb +26 -0
- data/lib/jade/type/function.rb +11 -2
- data/lib/jade/type.rb +36 -10
- data/lib/jade/version.rb +1 -1
- data/lib/jade.rb +1 -0
- metadata +35 -3
- data/lib/jade/frontend/type_checking/constraints/deriving/assignable.rb +0 -170
data/lib/jade/task.rb
CHANGED
|
@@ -1,102 +1,120 @@
|
|
|
1
|
-
require 'jade/tasks'
|
|
2
|
-
|
|
3
1
|
module Jade
|
|
4
2
|
module Task
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
in
|
|
3
|
+
# Every node is a value describing work, and `run` drives them from one
|
|
4
|
+
# loop with an explicit stack of continuations. Composing tasks therefore
|
|
5
|
+
# costs heap, not Ruby stack, so a chain built by recursion (a batch loop,
|
|
6
|
+
# a retry) is bounded by memory rather than by SystemStackError.
|
|
7
|
+
def run
|
|
8
|
+
task = self
|
|
9
|
+
pending = []
|
|
10
|
+
|
|
11
|
+
loop do
|
|
12
|
+
case task
|
|
13
|
+
in AndThen[inner, fn]
|
|
14
|
+
task = inner
|
|
15
|
+
pending << [:ok, fn]
|
|
16
|
+
|
|
17
|
+
in OnError[inner, fn]
|
|
18
|
+
task = inner
|
|
19
|
+
pending << [:err, fn]
|
|
20
|
+
|
|
21
|
+
in Map[inner, fn]
|
|
22
|
+
task = inner
|
|
23
|
+
pending << [:map, fn]
|
|
24
|
+
|
|
25
|
+
in MapError[inner, fn]
|
|
26
|
+
task = inner
|
|
27
|
+
pending << [:map_err, fn]
|
|
28
|
+
|
|
29
|
+
in Decoded[inner, ok_decoder, err_decoder]
|
|
30
|
+
task = inner
|
|
31
|
+
pending << [:decode, [ok_decoder, err_decoder]]
|
|
32
|
+
|
|
33
|
+
else
|
|
34
|
+
result = task.step
|
|
35
|
+
return result if pending.empty?
|
|
36
|
+
|
|
37
|
+
task = resume(result, pending)
|
|
38
|
+
return task if task.is_a?(Jade::Result::Ok) || task.is_a?(Jade::Result::Err)
|
|
28
39
|
end
|
|
29
40
|
end
|
|
30
41
|
end
|
|
31
42
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# Applies continuations to a settled result until one of them produces a
|
|
46
|
+
# fresh task to run, or the stack empties.
|
|
47
|
+
def resume(result, pending)
|
|
48
|
+
until pending.empty?
|
|
49
|
+
kind, fn = pending.pop
|
|
50
|
+
|
|
51
|
+
result =
|
|
52
|
+
case [kind, result]
|
|
53
|
+
in [:decode, _] then Decoded.decode_result(result, *fn)
|
|
54
|
+
in [:ok, Jade::Result::Ok[value]] then return fn.call(value)
|
|
55
|
+
in [:err, Jade::Result::Err[error]] then return fn.call(error)
|
|
56
|
+
in [:map, Jade::Result::Ok[value]] then Jade::Result::Ok[fn.call(value)]
|
|
57
|
+
in [:map_err, Jade::Result::Err[error]] then Jade::Result::Err[fn.call(error)]
|
|
58
|
+
else result
|
|
59
|
+
end
|
|
40
60
|
end
|
|
61
|
+
|
|
62
|
+
result
|
|
41
63
|
end
|
|
42
64
|
|
|
43
|
-
|
|
65
|
+
Literal = Data.define(:result) do
|
|
44
66
|
include Task
|
|
45
67
|
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
in Jade::Result::Ok => ok then ok
|
|
49
|
-
in Jade::Result::Err[error] then fn.call(error).run
|
|
50
|
-
end
|
|
68
|
+
def step
|
|
69
|
+
result
|
|
51
70
|
end
|
|
52
71
|
end
|
|
53
72
|
|
|
54
|
-
|
|
73
|
+
Dispatch = Data.define(:task_def, :args) do
|
|
55
74
|
include Task
|
|
56
75
|
|
|
57
|
-
def
|
|
58
|
-
|
|
59
|
-
in Jade::Result::Ok => ok then ok
|
|
60
|
-
in Jade::Result::Err[error] then Jade::Result::Err[fn.call(error)]
|
|
61
|
-
end
|
|
76
|
+
def step
|
|
77
|
+
Jade::Tasks.dispatch(task_def, *args)
|
|
62
78
|
end
|
|
63
79
|
end
|
|
64
80
|
|
|
65
81
|
Sequence = Data.define(:tasks) do
|
|
66
82
|
include Task
|
|
67
83
|
|
|
68
|
-
def
|
|
84
|
+
def step
|
|
69
85
|
values = []
|
|
86
|
+
|
|
70
87
|
tasks.each do |task|
|
|
71
88
|
case task.run
|
|
72
89
|
in Jade::Result::Ok[value] then values << value
|
|
73
90
|
in Jade::Result::Err => err then return err
|
|
74
91
|
end
|
|
75
92
|
end
|
|
93
|
+
|
|
76
94
|
Jade::Result::Ok[values]
|
|
77
95
|
end
|
|
78
96
|
end
|
|
79
97
|
|
|
98
|
+
Map = Data.define(:task, :fn) { include Task }
|
|
99
|
+
AndThen = Data.define(:task, :fn) { include Task }
|
|
100
|
+
OnError = Data.define(:task, :fn) { include Task }
|
|
101
|
+
MapError = Data.define(:task, :fn) { include Task }
|
|
102
|
+
|
|
80
103
|
Decoded = Data.define(:task, :ok_decoder, :err_decoder) do
|
|
81
104
|
include Task
|
|
82
105
|
|
|
83
|
-
def
|
|
84
|
-
case
|
|
85
|
-
in Jade::Result::Ok[value]
|
|
86
|
-
|
|
87
|
-
in Jade::Result::Err[error]
|
|
88
|
-
Jade::Result::Err[decode(err_decoder, error)]
|
|
106
|
+
def self.decode_result(result, ok_decoder, err_decoder)
|
|
107
|
+
case result
|
|
108
|
+
in Jade::Result::Ok[value] then Jade::Result::Ok[decode(ok_decoder, value)]
|
|
109
|
+
in Jade::Result::Err[error] then Jade::Result::Err[decode(err_decoder, error)]
|
|
89
110
|
end
|
|
90
111
|
end
|
|
91
112
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def decode(decoder, value)
|
|
113
|
+
def self.decode(decoder, value)
|
|
95
114
|
Jade::Decode::Runner.run!(decoder, value) do |error|
|
|
96
115
|
fail Jade::Interop::DecodeError.new(error, value, source: :port_return)
|
|
97
116
|
end
|
|
98
117
|
end
|
|
99
118
|
end
|
|
100
|
-
|
|
101
119
|
end
|
|
102
120
|
end
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
module Jade
|
|
2
2
|
module Type
|
|
3
|
-
AnonymousRecord = Data.define(:fields, :row_var) do
|
|
3
|
+
AnonymousRecord = Data.define(:fields, :row_var, :display) do
|
|
4
4
|
include Base
|
|
5
|
+
include Displayable
|
|
5
6
|
|
|
6
|
-
def
|
|
7
|
+
def initialize(fields:, row_var:, display: nil)
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def identity
|
|
12
|
+
[fields, row_var]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def render
|
|
7
16
|
row = row_var ? "#{row_var} | " : ""
|
|
8
17
|
|
|
9
18
|
fields
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
module Jade
|
|
2
2
|
module Type
|
|
3
|
-
Application = Data.define(:constructor, :args) do
|
|
3
|
+
Application = Data.define(:constructor, :args, :display) do
|
|
4
4
|
include Base
|
|
5
|
+
include Displayable
|
|
5
6
|
|
|
6
|
-
def
|
|
7
|
+
def initialize(constructor:, args:, display: nil)
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def identity
|
|
12
|
+
[constructor, args]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def render
|
|
7
16
|
return constructor.to_s if args.empty?
|
|
8
17
|
|
|
9
18
|
if constructor.name.start_with?('Tuple.Tuple')
|
data/lib/jade/type/base.rb
CHANGED
|
@@ -5,5 +5,31 @@ module Jade
|
|
|
5
5
|
fail NotImplementedError
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
module Displayable
|
|
10
|
+
def display_as(name)
|
|
11
|
+
with(display: name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
display || render
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def annotated
|
|
19
|
+
display ? "#{display} (= #{with(display: nil)})" : render
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# `display` is deliberately out of `identity`: two spellings of one type
|
|
23
|
+
# must still unify, hash alike and compare equal.
|
|
24
|
+
def ==(other)
|
|
25
|
+
other.is_a?(self.class) && identity == other.identity
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
alias eql? ==
|
|
29
|
+
|
|
30
|
+
def hash
|
|
31
|
+
[self.class, *identity].hash
|
|
32
|
+
end
|
|
33
|
+
end
|
|
8
34
|
end
|
|
9
35
|
end
|
data/lib/jade/type/function.rb
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
module Jade
|
|
2
2
|
module Type
|
|
3
|
-
Function = Data.define(:args, :return_type) do
|
|
3
|
+
Function = Data.define(:args, :return_type, :display) do
|
|
4
4
|
include Base
|
|
5
|
+
include Displayable
|
|
5
6
|
|
|
6
|
-
def
|
|
7
|
+
def initialize(args:, return_type:, display: nil)
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def identity
|
|
12
|
+
[args, return_type]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def render
|
|
7
16
|
args
|
|
8
17
|
.map(&:to_s).join(', ')
|
|
9
18
|
.then { "(#{it})"} + " -> " + return_type.to_s
|
data/lib/jade/type.rb
CHANGED
|
@@ -60,8 +60,8 @@ module Jade
|
|
|
60
60
|
[args, return_type]
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def anonymous_record(fields, row_var)
|
|
64
|
-
AnonymousRecord[fields, row_var]
|
|
63
|
+
def anonymous_record(fields, row_var, display = nil)
|
|
64
|
+
AnonymousRecord[fields, row_var, display]
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def constraint(interface_id, type, origin, index: :unindex)
|
|
@@ -246,17 +246,43 @@ module Jade
|
|
|
246
246
|
[Type::Application[constructor_type, arg_types], union_cs + args_cs, args_map]
|
|
247
247
|
|
|
248
248
|
in Symbol::TypeApplication(constructor:, args:)
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
resolved_head = constructor.is_a?(Symbol::TypeRef) ? registry.lookup(constructor) : constructor
|
|
250
|
+
|
|
251
|
+
if resolved_head.is_a?(Symbol::Alias)
|
|
252
|
+
arg_types, args_cs, args_map = args
|
|
253
|
+
.reduce([[], [], var_map]) do |(types, cs, local_map), sym|
|
|
254
|
+
from_symbol_r(sym, registry, var_gen, local_map)
|
|
255
|
+
.then { |(t, c, new_map)| [types + [t], cs + c, new_map] }
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
alias_var_map = resolved_head.type_params.map(&:name).zip(arg_types).to_h
|
|
259
|
+
|
|
260
|
+
body_type, body_cs, _ = from_symbol_r(resolved_head.body, registry, var_gen, alias_var_map)
|
|
261
|
+
display = arg_types.empty? ?
|
|
262
|
+
resolved_head.name :
|
|
263
|
+
"#{resolved_head.name}(#{arg_types.join(', ')})"
|
|
264
|
+
[display_as(body_type, display), args_cs + body_cs, args_map]
|
|
265
|
+
else
|
|
266
|
+
constructor_type, union_cs, union_vars =
|
|
267
|
+
from_symbol_r(constructor, registry, var_gen, var_map)
|
|
251
268
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
269
|
+
arg_types, args_cs, args_map = args
|
|
270
|
+
.reduce([[], [], union_vars]) do |(types, cs, local_map), sym|
|
|
271
|
+
from_symbol_r(sym, registry, var_gen, local_map)
|
|
272
|
+
.then { |(t, c, new_map)| [types + [t], cs + c, new_map] }
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
[Type.constructor(constructor.qualified_name).apply(arg_types), union_cs + args_cs, args_map]
|
|
276
|
+
end
|
|
257
277
|
|
|
258
|
-
|
|
278
|
+
in Symbol::Alias(body:)
|
|
279
|
+
from_symbol_r(body, registry, var_gen, var_map)
|
|
280
|
+
.then { |(type, cs, map)| [display_as(type, symbol.name), cs, map] }
|
|
259
281
|
end
|
|
260
282
|
end
|
|
283
|
+
|
|
284
|
+
def display_as(type, name)
|
|
285
|
+
type.is_a?(Displayable) ? type.display_as(name) : type
|
|
286
|
+
end
|
|
261
287
|
end
|
|
262
288
|
end
|
data/lib/jade/version.rb
CHANGED
data/lib/jade.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jade-lang
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Agustin Cornu
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-09-03 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|
|
@@ -55,6 +55,7 @@ files:
|
|
|
55
55
|
- lib/jade/calendar/runtime.rb
|
|
56
56
|
- lib/jade/cli.rb
|
|
57
57
|
- lib/jade/cli/check.rb
|
|
58
|
+
- lib/jade/cli/eject.rb
|
|
58
59
|
- lib/jade/cli/fmt.rb
|
|
59
60
|
- lib/jade/cli/lsp.rb
|
|
60
61
|
- lib/jade/cli/q.rb
|
|
@@ -78,6 +79,7 @@ files:
|
|
|
78
79
|
- lib/jade/codegen/inline.rb
|
|
79
80
|
- lib/jade/codegen/inlines.rb
|
|
80
81
|
- lib/jade/codegen/method_names.rb
|
|
82
|
+
- lib/jade/codegen/names.rb
|
|
81
83
|
- lib/jade/codegen/pattern/constructor.rb
|
|
82
84
|
- lib/jade/codegen/port_codec.rb
|
|
83
85
|
- lib/jade/codegen/pretty.rb
|
|
@@ -93,6 +95,7 @@ files:
|
|
|
93
95
|
- lib/jade/did_you_mean.rb
|
|
94
96
|
- lib/jade/entry.rb
|
|
95
97
|
- lib/jade/error.rb
|
|
98
|
+
- lib/jade/extensions.rb
|
|
96
99
|
- lib/jade/formatter.rb
|
|
97
100
|
- lib/jade/formatter/accesses.rb
|
|
98
101
|
- lib/jade/formatter/bindings.rb
|
|
@@ -121,7 +124,10 @@ files:
|
|
|
121
124
|
- lib/jade/frontend/forward_declaration.rb
|
|
122
125
|
- lib/jade/frontend/forward_declaration/body.rb
|
|
123
126
|
- lib/jade/frontend/forward_declaration/error.rb
|
|
127
|
+
- lib/jade/frontend/forward_declaration/error/alias_expansion.rb
|
|
124
128
|
- lib/jade/frontend/forward_declaration/error/bad_import.rb
|
|
129
|
+
- lib/jade/frontend/forward_declaration/error/duplicate_constructor_name.rb
|
|
130
|
+
- lib/jade/frontend/forward_declaration/error/duplicate_type_name.rb
|
|
125
131
|
- lib/jade/frontend/forward_declaration/error/exposed_type_not_found.rb
|
|
126
132
|
- lib/jade/frontend/forward_declaration/error/exposed_value_not_found.rb
|
|
127
133
|
- lib/jade/frontend/forward_declaration/error/module_not_found.rb
|
|
@@ -139,10 +145,16 @@ files:
|
|
|
139
145
|
- lib/jade/frontend/forward_declaration/interop_import_declaration.rb
|
|
140
146
|
- lib/jade/frontend/forward_declaration/module.rb
|
|
141
147
|
- lib/jade/frontend/forward_declaration/struct_declaration.rb
|
|
148
|
+
- lib/jade/frontend/forward_declaration/type_alias_declaration.rb
|
|
142
149
|
- lib/jade/frontend/forward_declaration/type_declaration.rb
|
|
143
150
|
- lib/jade/frontend/pattern_analysis.rb
|
|
144
151
|
- lib/jade/frontend/pattern_analysis/exhaustiveness.rb
|
|
145
152
|
- lib/jade/frontend/pattern_analysis/matrix.rb
|
|
153
|
+
- lib/jade/frontend/pattern_analysis/pattern.rb
|
|
154
|
+
- lib/jade/frontend/pattern_analysis/redundancy.rb
|
|
155
|
+
- lib/jade/frontend/pattern_analysis/signature.rb
|
|
156
|
+
- lib/jade/frontend/pattern_analysis/usefulness.rb
|
|
157
|
+
- lib/jade/frontend/pattern_analysis/witnesses.rb
|
|
146
158
|
- lib/jade/frontend/semantic_analysis.rb
|
|
147
159
|
- lib/jade/frontend/semantic_analysis/assign.rb
|
|
148
160
|
- lib/jade/frontend/semantic_analysis/body.rb
|
|
@@ -157,7 +169,9 @@ files:
|
|
|
157
169
|
- lib/jade/frontend/semantic_analysis/error/constructor_pattern_arity_mismatch.rb
|
|
158
170
|
- lib/jade/frontend/semantic_analysis/error/duplicate_field.rb
|
|
159
171
|
- lib/jade/frontend/semantic_analysis/error/duplicate_function_declaration.rb
|
|
172
|
+
- lib/jade/frontend/semantic_analysis/error/duplicate_implementation.rb
|
|
160
173
|
- lib/jade/frontend/semantic_analysis/error/duplicate_record_field.rb
|
|
174
|
+
- lib/jade/frontend/semantic_analysis/error/implementation_on_alias.rb
|
|
161
175
|
- lib/jade/frontend/semantic_analysis/error/invalid_list_rest_pattern.rb
|
|
162
176
|
- lib/jade/frontend/semantic_analysis/error/kwargs_on_non_constructor.rb
|
|
163
177
|
- lib/jade/frontend/semantic_analysis/error/missing_exposing_clause.rb
|
|
@@ -166,11 +180,13 @@ files:
|
|
|
166
180
|
- lib/jade/frontend/semantic_analysis/error/missing_implementation_function.rb
|
|
167
181
|
- lib/jade/frontend/semantic_analysis/error/module_not_found.rb
|
|
168
182
|
- lib/jade/frontend/semantic_analysis/error/nested_task_port.rb
|
|
183
|
+
- lib/jade/frontend/semantic_analysis/error/no_base_case.rb
|
|
169
184
|
- lib/jade/frontend/semantic_analysis/error/non_task_port.rb
|
|
170
185
|
- lib/jade/frontend/semantic_analysis/error/orphan_implementation.rb
|
|
171
186
|
- lib/jade/frontend/semantic_analysis/error/placeholder_not_allowed.rb
|
|
172
187
|
- lib/jade/frontend/semantic_analysis/error/predicate_must_return_bool.rb
|
|
173
188
|
- lib/jade/frontend/semantic_analysis/error/predicate_name_not_allowed.rb
|
|
189
|
+
- lib/jade/frontend/semantic_analysis/error/recursive_type_alias.rb
|
|
174
190
|
- lib/jade/frontend/semantic_analysis/error/shadowing_error.rb
|
|
175
191
|
- lib/jade/frontend/semantic_analysis/error/type_args_mismatch.rb
|
|
176
192
|
- lib/jade/frontend/semantic_analysis/error/type_param_required.rb
|
|
@@ -189,6 +205,7 @@ files:
|
|
|
189
205
|
- lib/jade/frontend/semantic_analysis/implementation.rb
|
|
190
206
|
- lib/jade/frontend/semantic_analysis/implementation_function.rb
|
|
191
207
|
- lib/jade/frontend/semantic_analysis/import_declaration.rb
|
|
208
|
+
- lib/jade/frontend/semantic_analysis/inhabitedness.rb
|
|
192
209
|
- lib/jade/frontend/semantic_analysis/interface_declaration.rb
|
|
193
210
|
- lib/jade/frontend/semantic_analysis/interop_import_declaration.rb
|
|
194
211
|
- lib/jade/frontend/semantic_analysis/keyed_call.rb
|
|
@@ -202,6 +219,7 @@ files:
|
|
|
202
219
|
- lib/jade/frontend/semantic_analysis/pattern_constructor.rb
|
|
203
220
|
- lib/jade/frontend/semantic_analysis/pattern_list.rb
|
|
204
221
|
- lib/jade/frontend/semantic_analysis/pattern_literal.rb
|
|
222
|
+
- lib/jade/frontend/semantic_analysis/pattern_range.rb
|
|
205
223
|
- lib/jade/frontend/semantic_analysis/pattern_record.rb
|
|
206
224
|
- lib/jade/frontend/semantic_analysis/pattern_wildcard.rb
|
|
207
225
|
- lib/jade/frontend/semantic_analysis/qualified_access.rb
|
|
@@ -211,14 +229,16 @@ files:
|
|
|
211
229
|
- lib/jade/frontend/semantic_analysis/record_update.rb
|
|
212
230
|
- lib/jade/frontend/semantic_analysis/struct_declaration.rb
|
|
213
231
|
- lib/jade/frontend/semantic_analysis/tuple.rb
|
|
232
|
+
- lib/jade/frontend/semantic_analysis/type_alias_declaration.rb
|
|
233
|
+
- lib/jade/frontend/semantic_analysis/type_alias_declaration/cycle_detection.rb
|
|
214
234
|
- lib/jade/frontend/semantic_analysis/type_declaration.rb
|
|
215
235
|
- lib/jade/frontend/semantic_analysis/variable_reference.rb
|
|
216
236
|
- lib/jade/frontend/semantic_analysis/variant_declaration.rb
|
|
217
237
|
- lib/jade/frontend/type_checking.rb
|
|
218
238
|
- lib/jade/frontend/type_checking/canonicalize.rb
|
|
239
|
+
- lib/jade/frontend/type_checking/cascade.rb
|
|
219
240
|
- lib/jade/frontend/type_checking/constraints.rb
|
|
220
241
|
- lib/jade/frontend/type_checking/constraints/deriving.rb
|
|
221
|
-
- lib/jade/frontend/type_checking/constraints/deriving/assignable.rb
|
|
222
242
|
- lib/jade/frontend/type_checking/constraints/deriving/decodable.rb
|
|
223
243
|
- lib/jade/frontend/type_checking/constraints/deriving/encodable.rb
|
|
224
244
|
- lib/jade/frontend/type_checking/constraints/deriving/eq.rb
|
|
@@ -229,6 +249,9 @@ files:
|
|
|
229
249
|
- lib/jade/frontend/type_checking/error.rb
|
|
230
250
|
- lib/jade/frontend/type_checking/error/case_of_branches_type_mismatch.rb
|
|
231
251
|
- lib/jade/frontend/type_checking/error/derivation_failed.rb
|
|
252
|
+
- lib/jade/frontend/type_checking/error/display.rb
|
|
253
|
+
- lib/jade/frontend/type_checking/error/division_by_zero.rb
|
|
254
|
+
- lib/jade/frontend/type_checking/error/empty_range_pattern.rb
|
|
232
255
|
- lib/jade/frontend/type_checking/error/function_body_type_mismatch.rb
|
|
233
256
|
- lib/jade/frontend/type_checking/error/function_call_type_mismatch.rb
|
|
234
257
|
- lib/jade/frontend/type_checking/error/if_branch_type_mismatch.rb
|
|
@@ -241,8 +264,11 @@ files:
|
|
|
241
264
|
- lib/jade/frontend/type_checking/error/pattern_type_mismatch.rb
|
|
242
265
|
- lib/jade/frontend/type_checking/error/port_not_decodable.rb
|
|
243
266
|
- lib/jade/frontend/type_checking/error/port_not_encodable.rb
|
|
267
|
+
- lib/jade/frontend/type_checking/error/range_pattern_type.rb
|
|
244
268
|
- lib/jade/frontend/type_checking/error/record_access_type_mismatch.rb
|
|
269
|
+
- lib/jade/frontend/type_checking/error/recursive_derivation.rb
|
|
245
270
|
- lib/jade/frontend/type_checking/error/type_mismatch.rb
|
|
271
|
+
- lib/jade/frontend/type_checking/error/unreachable_branch.rb
|
|
246
272
|
- lib/jade/frontend/type_checking/error/unresolved_constraint.rb
|
|
247
273
|
- lib/jade/frontend/type_checking/expected.rb
|
|
248
274
|
- lib/jade/frontend/type_checking/generalization.rb
|
|
@@ -252,6 +278,7 @@ files:
|
|
|
252
278
|
- lib/jade/frontend/type_checking/inference/body.rb
|
|
253
279
|
- lib/jade/frontend/type_checking/inference/case_of.rb
|
|
254
280
|
- lib/jade/frontend/type_checking/inference/constructor_reference.rb
|
|
281
|
+
- lib/jade/frontend/type_checking/inference/division.rb
|
|
255
282
|
- lib/jade/frontend/type_checking/inference/function_call.rb
|
|
256
283
|
- lib/jade/frontend/type_checking/inference/function_declaration.rb
|
|
257
284
|
- lib/jade/frontend/type_checking/inference/grouping.rb
|
|
@@ -272,6 +299,7 @@ files:
|
|
|
272
299
|
- lib/jade/frontend/type_checking/inference/record_literal.rb
|
|
273
300
|
- lib/jade/frontend/type_checking/inference/record_update.rb
|
|
274
301
|
- lib/jade/frontend/type_checking/inference/struct_declaration.rb
|
|
302
|
+
- lib/jade/frontend/type_checking/inference/type_alias_declaration.rb
|
|
275
303
|
- lib/jade/frontend/type_checking/inference/type_declaration.rb
|
|
276
304
|
- lib/jade/frontend/type_checking/inference/variable_reference.rb
|
|
277
305
|
- lib/jade/frontend/type_checking/instantiation.rb
|
|
@@ -301,6 +329,7 @@ files:
|
|
|
301
329
|
- lib/jade/lsp/snippets.rb
|
|
302
330
|
- lib/jade/lsp/state.rb
|
|
303
331
|
- lib/jade/module_loader.rb
|
|
332
|
+
- lib/jade/module_loader/build.rb
|
|
304
333
|
- lib/jade/module_loader/cache.rb
|
|
305
334
|
- lib/jade/module_loader/dependency_graph.rb
|
|
306
335
|
- lib/jade/module_loader/dependency_resolver.rb
|
|
@@ -335,6 +364,8 @@ files:
|
|
|
335
364
|
- lib/jade/stdlib/intrinsics.rb
|
|
336
365
|
- lib/jade/stdlib/list.rb
|
|
337
366
|
- lib/jade/stdlib/maybe.rb
|
|
367
|
+
- lib/jade/stdlib/number.rb
|
|
368
|
+
- lib/jade/stdlib/range.rb
|
|
338
369
|
- lib/jade/stdlib/result.rb
|
|
339
370
|
- lib/jade/stdlib/set.rb
|
|
340
371
|
- lib/jade/stdlib/show.rb
|
|
@@ -343,6 +374,7 @@ files:
|
|
|
343
374
|
- lib/jade/stdlib/text.rb
|
|
344
375
|
- lib/jade/stdlib/tuple.rb
|
|
345
376
|
- lib/jade/symbol.rb
|
|
377
|
+
- lib/jade/symbol/alias.rb
|
|
346
378
|
- lib/jade/symbol/anonymous_record.rb
|
|
347
379
|
- lib/jade/symbol/base.rb
|
|
348
380
|
- lib/jade/symbol/constructor.rb
|