-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support circular and out-of-order trait/type references (#47)
Long overdue. This allows types and traits to be defined in any order **within a package** (circular type dependencies will never be allowed outside of a package because Crochet's capabilities require a proper hierarchy of dependencies), and can finally get rid of the awkward `0-types.crochet` convention. Types and traits can now be defined wherever makes most sense for them to be, and circular constraints now work properly. This fixes #10.
- Loading branch information
1 parent
db80c25
commit d233998
Showing
14 changed files
with
271 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
% crochet | ||
|
||
trait test-trait-a with | ||
command Type check; | ||
end | ||
|
||
local singleton a; | ||
local singleton b; | ||
implement test-trait-a for a; | ||
command a check = true; | ||
command b check = true; | ||
command (W has test-trait-a) check-trait-a = W check; | ||
|
||
test "Trait dispatch works" do | ||
assert a check === true; | ||
assert a check-trait-a === true; | ||
end | ||
|
||
test "Trait assertions work" do | ||
assert a has test-trait-a; | ||
assert not (b has test-trait-a); | ||
end | ||
|
||
implement test-trait-b for b; | ||
command (W has test-trait-b) check-trait-b = W check; | ||
|
||
trait test-trait-b with | ||
command T check-trait-b; | ||
end | ||
|
||
test "Traits can be defined after constraints" do | ||
assert b check === true; | ||
assert b check-trait-b === true; | ||
assert b has test-trait-b; | ||
assert not (b has test-trait-a); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
% crochet | ||
|
||
type placeholder-type-after; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
% crochet | ||
|
||
type placeholder-type-before(value is future-type1); |
Oops, something went wrong.