-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also, an experimental extensible pattern-matching implementation.
- Loading branch information
1 parent
8fe3432
commit 51116cd
Showing
30 changed files
with
710 additions
and
68 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
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,4 @@ | ||
# Reference | ||
|
||
0. [ts-fold: Code-folding using tree-sitter](https://github.com/emacs-tree-sitter/ts-fold) | ||
|
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,43 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
... ["Type-safe pattern combinators" by Morten Rhiger](https://core.ac.uk/works/9613163) | ||
(.require | ||
[library | ||
[lux (.except Pattern | ||
when) | ||
[control | ||
[pure (.only Pure)] | ||
[function | ||
[predicate (.only Predicate)]]] | ||
[meta | ||
["[0]" type]]]] | ||
[/ | ||
["[0]" input] | ||
["[0]" match] | ||
["[0]" pattern] | ||
["[0]" clause (.only Clause Pattern)]]) | ||
|
||
(the .public (when input clause) | ||
(All (_ input value) | ||
(-> input (Clause input value) | ||
value)) | ||
(clause input | ||
(function (_ _) | ||
(undefined)))) | ||
|
||
(the .public (match? pattern input) | ||
(All (_ of) | ||
(-> (Pattern of Bit Bit) | ||
(Predicate of))) | ||
(<| (..when input) | ||
(all clause.or | ||
(clause.clause pattern true) | ||
(clause.clause pattern.any false)))) | ||
|
||
(the .public (abstraction pattern body) | ||
(All (_ term input value) | ||
(-> (Pattern input term value) term | ||
(-> input value))) | ||
(function (_ input) | ||
(..when input (clause.clause pattern body)))) |
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,68 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.require | ||
[library | ||
[lux (.except or and) | ||
[meta | ||
["[0]" type]]]] | ||
[// | ||
["[0]" input] | ||
["[0]" output]]) | ||
|
||
(every .public (Then arity value) | ||
(-> arity | ||
value)) | ||
|
||
(every .public Constant | ||
(Then input.Zero)) | ||
|
||
(every .public Else | ||
Constant) | ||
|
||
(every .public (Body outer inner value) | ||
(-> (Then inner value) (Else value) | ||
(Then outer value))) | ||
|
||
(every .public Zero | ||
(All (_ arity value) | ||
(Body arity arity value))) | ||
|
||
(the .public success | ||
Zero | ||
(function (_ next exit) | ||
next)) | ||
|
||
(every .public (Succ of) | ||
(All (_ arity value) | ||
(|> (Body arity (input.Succ of arity) value) | ||
(output.Succ of)))) | ||
|
||
(the .public (succ value) | ||
Succ | ||
(function (_ next exit stack) | ||
(next (input.succ value stack)))) | ||
|
||
(the .public failure | ||
Body | ||
(function (_ next exit stack) | ||
(exit (input.zero)))) | ||
|
||
(the .public (or left right) | ||
(All (_ arity_0 arity_1 value) | ||
(type.let [choice (Body arity_0 arity_1 value)] | ||
(-> choice choice | ||
choice))) | ||
(function (_ next exit stack) | ||
(left next | ||
(function (_ _) | ||
(right next exit stack)) | ||
stack))) | ||
|
||
(the .public (and left right) | ||
(All (_ arity_0 arity_1 arity_2 value) | ||
(-> (Body arity_1 arity_0 value) | ||
(Body arity_2 arity_1 value) | ||
(Body arity_2 arity_0 value))) | ||
(function (_ input exit stack) | ||
(right (left input exit) exit stack))) |
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,40 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.require | ||
[library | ||
[lux (.except Pattern | ||
or) | ||
[meta | ||
["[0]" type]]]] | ||
[// | ||
["[0]" input] | ||
["[0]" match] | ||
["[0]" body (.only Body)]]) | ||
|
||
(every .public (Pattern input negative value) | ||
(Ex (_ arity) | ||
(type.let [positive (body.Then arity value)] | ||
[(-> match.Constant (-> negative positive)) | ||
(-> input (Body input.Zero arity value))]))) | ||
|
||
(every .public (Clause input value) | ||
(-> input (body.Else value) | ||
value)) | ||
|
||
(the .public (clause pattern body) | ||
(All (_ input term value) | ||
(-> (Pattern input term value) term | ||
(Clause input value))) | ||
(function (_ input exit) | ||
(let [[number match] pattern] | ||
((match input) (number match.constant body) exit [])))) | ||
|
||
(the .public (or left right) | ||
(All (_ input value) | ||
(-> (Clause input value) (Clause input value) | ||
(Clause input value))) | ||
(function (_ input exit) | ||
(left input | ||
(function (_ _) | ||
(right input exit))))) |
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,23 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.require | ||
[library | ||
[lux (.except)]]) | ||
|
||
(every .public Zero | ||
[]) | ||
|
||
(the .public zero | ||
(template (_) | ||
[[]])) | ||
|
||
(every .public (One of) | ||
of) | ||
|
||
(every .public (Succ of pred) | ||
(And of pred)) | ||
|
||
(the .public succ | ||
(template (_ of pred) | ||
[[of pred]])) |
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,45 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.require | ||
[library | ||
[lux (.except)]] | ||
[// | ||
["[0]" input] | ||
["[0]" output]]) | ||
|
||
(every .public (Match negative positive value) | ||
(-> negative positive | ||
value)) | ||
|
||
(every .public Constant | ||
(All (_ value) | ||
(Match (output.One value) input.Zero | ||
value))) | ||
|
||
(the .public constant | ||
Constant | ||
(function (_ one (input.zero)) | ||
one)) | ||
|
||
(every .public (Natural negative_change positive_change) | ||
(All (_ value negative positive) | ||
(-> (Match negative positive | ||
value) | ||
(Match (negative_change negative) (positive_change positive) | ||
value)))) | ||
|
||
(every .public Zero | ||
(Natural output.One input.One)) | ||
|
||
(the .public zero | ||
Zero | ||
(|>>)) | ||
|
||
(every .public (Succ of) | ||
(Natural (output.Succ of) (input.Succ of))) | ||
|
||
(the .public (succ pred) | ||
Succ | ||
(function (_ negative (input.succ ++ --)) | ||
(pred (negative ++) --))) |
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,14 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.require | ||
[library | ||
[lux (.except)]]) | ||
|
||
(every .public One | ||
(All (_ of) | ||
of)) | ||
|
||
(every .public (Succ of pred) | ||
(-> of | ||
pred)) |
Oops, something went wrong.