Skip to content

Commit

Permalink
Add OCaml style module aliases for re-exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Aug 27, 2023
1 parent 48c986d commit 0c8e3d5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ signature: Signature; l = nonempty_list(sig_item) { l }
| Defexternal; ident; sexp_type_expr; option(String_lit) { $loc, $2, $3, $4 }

modul:
| Module; id = ident { Module (id, [], []) } /* empty module */
| Module; id = ident; hd = module_item; m = list(top_item) { Module (id, [], hd :: m) }
| Module; id = ident; s = parens(signature); m = list(top_item) { Module (id, s, m) }
| Module; id = ident { Module_alias (id, Path.Pid (snd id)) }
| Module; id = ident; mname = path /* Use location of path */
{ Module_alias ((fst mname, snd id), snd mname) }
| Module; id = ident; hd = module_item; m = list(top_item) { Module (id, [], hd :: m) }
| Module; id = ident; s = parens(signature); m = list(top_item) { Module (id, s, m) }

%inline path:
| id = ident { $loc, Path.Pid (snd id) }
Expand Down
8 changes: 4 additions & 4 deletions std/std.smu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(do (f i) (inner (+ i 1)))))
(inner from))

(module array array)
(module hashtbl hashtbl)
(module option option)
(module string string)
(module array)
(module hashtbl)
(module option)
(module string)
2 changes: 1 addition & 1 deletion test/modules.t/local_module.smu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(def test (fun unit unit))
(def poly-test (fun 'a unit))
(def value string))
(module nested)
(module nested (type t unit))
(type t int)
(defn test [] (print "hey thing"))
(defn poly-test [a] (print (fmt-str "hey poly " a)))
Expand Down
2 changes: 1 addition & 1 deletion test/modules.t/local_otherfile.smu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(def test (fun unit unit))
(def poly-test (fun 'a unit))
(def value string))
(module nested)
(module nested (type t unit))
(type t int)
(defn test [] (print "hey thing"))
(defn poly-test [a] (print (fmt-str "hey poly " a)))
Expand Down
2 changes: 1 addition & 1 deletion test/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ let test_local_modules_miss_local_dont_find_global () =

let test_local_module_unique_names () =
test_exn "Module names must be unique. nosig exists already"
(local_module ^ "(module nosig)")
(local_module ^ "(module nosig (type t unit))")

let test_local_module_nested_module_alias () =
test "nosig/nested/t"
Expand Down

0 comments on commit 0c8e3d5

Please sign in to comment.