-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e51b990
commit 9821c32
Showing
5 changed files
with
156 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
:NewDefs | ||
:NoJS | ||
|
||
`42 | ||
//│ Code[42, nothing] | ||
|
||
x `=> x | ||
//│ Code[forall 'a. 'a -> 'a, nothing] | ||
|
||
x `=> | ||
x | ||
//│ Code[forall 'a. 'a -> 'a, nothing] | ||
|
||
run(x `=> x)(42) | ||
//│ 42 | ||
|
||
`1 `+ `1 | ||
//│ Code[Int, nothing] | ||
|
||
`(1 + 1) | ||
//│ Code[Int, nothing] | ||
|
||
x `=> x `+ `1 | ||
//│ Code[Int -> Int, nothing] | ||
|
||
y `=> `0 `- y | ||
//│ Code[Int -> Int, nothing] | ||
|
||
:e | ||
z `=> z + 1 | ||
//│ ╔══[ERROR] Type mismatch in operator application: | ||
//│ ║ l.30: z `=> z + 1 | ||
//│ ║ ^^^^^ | ||
//│ ╙── expression of type `Code[?a, ?z]` is not an instance of `Int` | ||
//│ ╔══[ERROR] Type mismatch in unquote: | ||
//│ ║ l.30: z `=> z + 1 | ||
//│ ║ ^^^^^ | ||
//│ ╙── operator application of type `Int` is not an instance of `Code[?a, ?z | ?b]` | ||
//│ Code[anything -> error, nothing] | ||
|
||
|
||
(x, y) `=> x `+ y | ||
//│ Code[(Int, Int) -> Int, nothing] | ||
|
||
run((x, y) `=> x `+ y)(1, 2) | ||
//│ Int |
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,8 @@ | ||
:NewDefs | ||
:NoJS | ||
|
||
|
||
fun power(x) = case | ||
0 then `1 | ||
n then x `* power(x)(n - 1) | ||
//│ fun power: forall 'a. Code[Int, 'a] -> (0 | Int & ~0) -> Code[Int, 'a] |