-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
27 changed files
with
306 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# wrong use of continuation notation | ||
@{Int}(Int) :: | ||
a = 1; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# this function is well typed in System F, not in Hindley-Milner | ||
# this function requires unrestricted quantification on types. | ||
Int :: | ||
one = (fn f. f succ (f 0)) (fn x. x); |
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
# this will fail due to non-exhaustive patterns: the case where list has only one element is missing. | ||
# furthermore, even if we add the "h : _" case, it will cause a type error because | ||
# the "a" type variable cannot be unified with type "Maybe a" due to the occurs check. | ||
|
||
[a] -> Maybe a :: | ||
safeHead xs c = match xs with | ||
| h : (Just x) : _ => c (Just h) | ||
| h : _ => c (Just h) | ||
| [] => c Nothing; | ||
| h : (Just x) : _ => c (Just h) | ||
| [] => c Nothing; |
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 @@ | ||
Cannot add continuation to non-function type 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
Type error occured: | ||
Cannot unify type [a103] with Maybe a104 | ||
Pattern group for expression EVar "xs" is non-exhaustive. |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Type error occured: | ||
Cannot unify type Int with (Int -> a107) -> a107 | ||
Cannot unify type Int with (Int -> a104) -> a104 |
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,34 @@ | ||
{# | ||
This is a library, it cannot be interpreted on its own. | ||
}# | ||
|
||
c : | ||
@{c}(a -> b) -> [a] -> [b] :: | ||
contMap f xs c = match xs with | ||
| [] => c [] | ||
| h:t => f h (\x . contMap f t (\rest . c (x : rest))); | ||
|
||
[a] -> Maybe a :: | ||
safeHead xs c = match xs with | ||
| h : _ => c (Just h) | ||
| [] => c Nothing; | ||
|
||
d : | ||
@{d}(a -> b -> c) -> [a] -> [b] -> [c] :: | ||
zipWith f xs ys c = match Pair xs ys with | ||
| Pair (x:tx) (y:ty) => f x y (\n . zipWith f tx ty (\rest . c (n : rest))) | ||
| _ => c []; | ||
|
||
c : | ||
[@{c}(a -> b)] -> [a] -> [b] :: | ||
apply fs xs c = match Pair fs xs with | ||
| Pair (f:frest) (x:xrest) => f x (\res . apply frest xrest (\l . c (res : l))) | ||
| _ => c []; | ||
|
||
[[a]] -> [a] :: | ||
contcat xs c = match xs with | ||
| l:ls => contcat ls (\res . c (l ++ res)) | ||
| [] => c []; | ||
|
||
[[[[[[a]]]]]] -> [a] :: | ||
superFlatten xs c = contcat xs (flip contcat (flip contcat (flip contcat (flip contcat c)))); |
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,12 @@ | ||
x = 1; | ||
|
||
y = x; | ||
|
||
f z c = c (z + x); | ||
|
||
test = | ||
let g = \_ . x in | ||
let x = 0 in | ||
f 0 (\res . res + y + g 20); | ||
|
||
main = const test; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
3 | ||
Just 3628800 |
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 |
Binary file not shown.
Oops, something went wrong.