-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 66-repl-bug-fix
- Loading branch information
Showing
37 changed files
with
686 additions
and
274 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import B/C/D | ||
|
||
pub let foo = D.id 42 |
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,2 @@ | ||
pub let id x = x | ||
pub let bar = 13 |
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 @@ | ||
(* This import resolves to the absolute path `/Main/B/A`. *) | ||
import A | ||
|
||
pub let id = A.id |
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 @@ | ||
pub let mod_C_value = 0 |
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,38 @@ | ||
(** This example serves to showcase the files-as-modules feature. | ||
|
||
The module hierarchy is as follows. | ||
``` | ||
/ | ||
├─ Main | ||
│ ├─ Main (this file) | ||
│ ├─ A (imports B/C/D, resolving to /Main/B/C/D) | ||
│ ├─ B | ||
│ │ ├─ A | ||
│ │ └─ C | ||
│ │ └─ D (imports A, resolving to /Main/B/A) | ||
│ └─ C | ||
├─ List | ||
⋮ | ||
``` | ||
Modules under `/Main/` are local to this example and follow its directory | ||
structure. Additionaly, the module `/List` from the standard library is | ||
imported. | ||
|
||
Relative imports refer to the module which is the closest to the importing | ||
module, working upwards through the hierarchy. In this example the module | ||
`/Main/B/C/D` imports the relative path `A`, and the nearest matching | ||
module is `/Main/B/A`. *) | ||
|
||
import List | ||
|
||
import A | ||
import B/C/D as X | ||
import /Main/B/C/D as Y (* The same import, but as an absolute path. *) | ||
import B/A as A2 | ||
|
||
(* Rather than binding a module name, import the module's contents *) | ||
import open C | ||
|
||
let _ = | ||
List.iter (fn x => printInt x; printStr "\n") | ||
[ X.id A.foo, Y.id A2.bar, mod_C_value ] |
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,37 @@ | ||
pub let map f = fix (fn map xs => | ||
match xs with | ||
| [] => [] | ||
| x :: xs => f x :: map xs | ||
end) | ||
|
||
pub let filter f = fix (fn filter xs => | ||
match xs with | ||
| [] => [] | ||
| x :: xs => if f x then x :: filter xs else filter xs | ||
end) | ||
|
||
pub let append xs ys = fix (fn append xs => | ||
match xs with | ||
| [] => ys | ||
| x :: xs => x :: append xs | ||
end) xs | ||
|
||
pub let concat = fix (fn concat xss => | ||
match xss with | ||
| [] => [] | ||
| xs :: xss => append xs (concat xss) | ||
end) | ||
|
||
pub let iter f = fix (fn iter xs => | ||
match xs with | ||
| [] => () | ||
| x :: xs => let () = f x in iter xs | ||
end) | ||
|
||
pub let iter2 {`re : {type X} -> Unit ->[|_] X} f = | ||
fix (fn iter xs ys => | ||
match xs, ys with | ||
| [], [] => () | ||
| x :: xs, y :: ys => let () = f x y in iter xs ys | ||
| _ => `re () | ||
end) |
Oops, something went wrong.