diff --git a/compiler/src/formatting/fmt.re b/compiler/src/formatting/fmt.re index 95d83943fc..a1751597d9 100644 --- a/compiler/src/formatting/fmt.re +++ b/compiler/src/formatting/fmt.re @@ -3212,8 +3212,9 @@ let print_primitive_description = (fmt, {pprim_ident, pprim_name, pprim_loc}) => ++ double_quotes(string(pprim_name.txt)); }; -let print_include_declaration = (fmt, {pinc_path, pinc_alias, pinc_loc}) => { - string("include") +let print_include_declaration = + (fmt, {pinc_path, pinc_module, pinc_alias, pinc_loc}) => { + string("from") ++ fmt.print_comment_range( fmt, ~allow_breaks=false, @@ -3224,6 +3225,17 @@ let print_include_declaration = (fmt, {pinc_path, pinc_alias, pinc_loc}) => { pinc_path.loc, ) ++ double_quotes(string(pinc_path.txt)) + ++ fmt.print_comment_range( + fmt, + ~allow_breaks=false, + ~none=space, + ~lead=space, + ~trail=space, + pinc_path.loc, + pinc_module.loc, + ) + ++ string("include ") + ++ string(pinc_module.txt) ++ ( switch (pinc_alias) { | None => empty @@ -3235,7 +3247,7 @@ let print_include_declaration = (fmt, {pinc_path, pinc_alias, pinc_loc}) => { ~none=space, ~lead=space, ~trail=space, - pinc_path.loc, + pinc_module.loc, alias_loc, ) ++ string(alias) diff --git a/compiler/src/language_server/inlayhint.re b/compiler/src/language_server/inlayhint.re index 2140c73cc7..b88cdf262f 100644 --- a/compiler/src/language_server/inlayhint.re +++ b/compiler/src/language_server/inlayhint.re @@ -40,27 +40,7 @@ let find_hints = program => { module Iterator = TypedtreeIter.MakeIterator({ include TypedtreeIter.DefaultIteratorArgument; - let enter_toplevel_stmt = (stmt: toplevel_stmt) => { - switch (stmt.ttop_desc) { - | TTopInclude(inc) => - let name = Path.name(inc.tinc_path); - - let stmt_loc = stmt.ttop_loc; - let stmt_end = stmt_loc.loc_end; - - let p: Protocol.position = { - line: stmt_end.pos_lnum - 1, - character: stmt_end.pos_cnum - stmt_end.pos_bol + 1 + 1, - }; - - let r: ResponseResult.inlay_hint = { - label: ": " ++ name, - position: p, - }; - hints := [r, ...hints^]; - | _ => () - }; - }; + // Inlay hints for various expressions can be included here. }); Iterator.iter_typed_program(program); hints^; diff --git a/compiler/src/parsing/ast_helper.re b/compiler/src/parsing/ast_helper.re index 9463d60852..905c2f6a99 100644 --- a/compiler/src/parsing/ast_helper.re +++ b/compiler/src/parsing/ast_helper.re @@ -472,9 +472,10 @@ module MatchBranch = { }; module IncludeDeclaration = { - let mk = (~loc, path, alias) => { + let mk = (~loc, path, module_, alias) => { { pinc_alias: alias, + pinc_module: module_, pinc_path: normalize_string(~loc, path), pinc_loc: loc, }; diff --git a/compiler/src/parsing/ast_helper.rei b/compiler/src/parsing/ast_helper.rei index 4155953938..384ea22360 100644 --- a/compiler/src/parsing/ast_helper.rei +++ b/compiler/src/parsing/ast_helper.rei @@ -540,7 +540,7 @@ module MatchBranch: { }; module IncludeDeclaration: { - let mk: (~loc: loc, str, option(str)) => include_declaration; + let mk: (~loc: loc, str, str, option(str)) => include_declaration; }; module TypeArgument: { diff --git a/compiler/src/parsing/ast_mapper.re b/compiler/src/parsing/ast_mapper.re index 39336774ac..ae61e5a051 100644 --- a/compiler/src/parsing/ast_mapper.re +++ b/compiler/src/parsing/ast_mapper.re @@ -530,9 +530,10 @@ module MB = { }; module I = { - let map = (sub, {pinc_alias, pinc_path, pinc_loc}) => { + let map = (sub, {pinc_module, pinc_alias, pinc_path, pinc_loc}) => { { pinc_path: map_loc(sub, pinc_path), + pinc_module: map_loc(sub, pinc_module), pinc_alias: Option.map(map_loc(sub), pinc_alias), pinc_loc: sub.location(sub, pinc_loc), }; diff --git a/compiler/src/parsing/parser.messages b/compiler/src/parsing/parser.messages index 9d87f3c344..6981cfc75f 100644 --- a/compiler/src/parsing/parser.messages +++ b/compiler/src/parsing/parser.messages @@ -54,7 +54,7 @@ program: MODULE UIDENT EOL MODULE YIELD ## The known suffix of the stack is as follows: ## MODULE ## -program: MODULE UIDENT EOL INCLUDE STRING AS YIELD +program: MODULE UIDENT EOL FROM STRING INCLUDE UIDENT AS YIELD ## ## Ends in an error in state: 741. ## @@ -328,7 +328,7 @@ program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON UIDENT AS EOL YIELD ## In state 6, spurious reduction of production eols -> nonempty_list(eol) ## In state 53, spurious reduction of production option(eols) -> eols ## -program: MODULE UIDENT EOL INCLUDE STRING AS EOL YIELD +program: MODULE UIDENT EOL FROM STRING INCLUDE UIDENT AS EOL YIELD ## ## Ends in an error in state: 823. ## @@ -3197,16 +3197,6 @@ program: MODULE UIDENT EOL IF WHILE Expected `(` followed by a condition expression. -program: MODULE UIDENT EOL INCLUDE WHILE -## -## Ends in an error in state: 874. -## -## import_stmt -> INCLUDE . lseparated_nonempty_list_inner(comma,import_shape) option(comma) FROM file_path [ SEMI EOL EOF ] -## toplevel_stmt -> attributes INCLUDE . foreign_stmt [ SEMI EOL EOF ] -## -## The known suffix of the stack is as follows: -## attributes INCLUDE -## program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON UIDENT FROM YIELD ## ## Ends in an error in state: 753. @@ -3225,10 +3215,43 @@ program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON EOL UIDENT FROM YIELD ## The known suffix of the stack is as follows: ## FOREIGN WASM id_str COLON eols typ option(as_prefix(id_str)) FROM ## +program: MODULE UIDENT EOL FROM YIELD +## +## Ends in an error in state: 862. +## +## include_stmt -> FROM . file_path INCLUDE qualified_uid option(include_alias) [ SEMI RBRACE EOL EOF ] +## +## The known suffix of the stack is as follows: +## FROM +## Expected a file path surrounded by `"`. -program: MODULE UIDENT EOL INCLUDE STRING YIELD +program: MODULE UIDENT EOL FROM STRING YIELD +## +## Ends in an error in state: 863. +## +## include_stmt -> FROM file_path . INCLUDE qualified_uid option(include_alias) [ SEMI RBRACE EOL EOF ] +## +## The known suffix of the stack is as follows: +## FROM file_path +## + +Expected the keyword `include` followed by a module identifier. + +program: MODULE UIDENT EOL FROM STRING INCLUDE YIELD +## +## Ends in an error in state: 864. +## +## include_stmt -> FROM file_path INCLUDE . qualified_uid option(include_alias) [ SEMI RBRACE EOL EOF ] +## +## The known suffix of the stack is as follows: +## FROM file_path INCLUDE +## + +Expected a module identifier. + +program: MODULE UIDENT EOL FROM STRING INCLUDE UIDENT YIELD ## ## Ends in an error in state: 740. ## diff --git a/compiler/src/parsing/parser.mly b/compiler/src/parsing/parser.mly index 6de35c374b..05d142eade 100644 --- a/compiler/src/parsing/parser.mly +++ b/compiler/src/parsing/parser.mly @@ -357,10 +357,10 @@ use_stmt: | USE qualified_uid_inline dot use_shape { Expression.use ~loc:(to_loc $loc) ~core_loc:(to_loc $loc) $2 $4 } include_alias: - | AS opt_eols qualified_uid { make_module_alias $3 } + | AS opt_eols qualified_uid { make_include_alias $3 } include_stmt: - | INCLUDE file_path include_alias? { IncludeDeclaration.mk ~loc:(to_loc $loc) $2 $3 } + | FROM file_path INCLUDE qualified_uid include_alias? { IncludeDeclaration.mk ~loc:(to_loc $loc) $2 (make_include_ident $4) $5 } data_declaration_stmt: | ABSTRACT data_declaration { (Abstract, $2, to_loc($loc)) } diff --git a/compiler/src/parsing/parser_header.re b/compiler/src/parsing/parser_header.re index 810286969b..789d6959d7 100644 --- a/compiler/src/parsing/parser_header.re +++ b/compiler/src/parsing/parser_header.re @@ -90,7 +90,20 @@ let mkid_expr = (loc, ns) => { let mkstr = (loc, s) => mkloc(s, to_loc(loc)); -let make_module_alias = ident => { +let make_include_ident = ident => { + switch (ident.txt) { + | IdentName(name) => name + | IdentExternal(_) => + raise( + SyntaxError( + ident.loc, + "A module include name cannot contain `.` as that would reference a binding within another module.", + ), + ) + }; +}; + +let make_include_alias = ident => { switch (ident.txt) { | IdentName(name) => name | IdentExternal(_) => diff --git a/compiler/src/parsing/parsetree.re b/compiler/src/parsing/parsetree.re index 4ec26e408d..8da79675f6 100644 --- a/compiler/src/parsing/parsetree.re +++ b/compiler/src/parsing/parsetree.re @@ -596,6 +596,7 @@ and match_branch = { [@deriving (sexp, yojson)] type include_declaration = { pinc_path: loc(string), + pinc_module: loc(string), pinc_alias: option(loc(string)), [@sexp_drop_if sexp_locs_disabled] pinc_loc: Location.t, diff --git a/compiler/src/typed/typemod.re b/compiler/src/typed/typemod.re index 11a5bb2e35..ee34b78afb 100644 --- a/compiler/src/typed/typemod.re +++ b/compiler/src/typed/typemod.re @@ -27,6 +27,7 @@ module String = Misc.Stdlib.String; type error = | Cannot_apply(module_type) | Not_included(list(Includemod.error)) + | Include_module_name_mismatch(string, string) | Cannot_eliminate_dependency(module_type) | Signature_expected | Structure_expected(module_type) @@ -77,6 +78,15 @@ let extract_sig_open = (env, loc, mty) => let include_module = (env, sod) => { let include_path = sod.pinc_path.txt; let mod_name = Env.load_pers_struct(~loc=sod.pinc_loc, include_path); + if (mod_name != sod.pinc_module.txt) { + raise( + Error( + sod.pinc_module.loc, + env, + Include_module_name_mismatch(sod.pinc_module.txt, mod_name), + ), + ); + }; let mod_name = switch (sod.pinc_alias) { | Some({txt: alias}) => alias @@ -1001,6 +1011,7 @@ let use_implicit_module = (m, env) => { let path = Typetexp.lookup_module(~load=true, env, loc, ident, filepath); let include_desc = { pinc_path: Location.mknoloc(filename), + pinc_module: Location.mknoloc(modname), pinc_alias: None, pinc_loc: loc, }; @@ -1081,6 +1092,15 @@ let report_error = ppf => Includemod.report_error, errs, ) + | Include_module_name_mismatch(provided_name, actual_name) => + fprintf( + ppf, + "This statement includes module %s, but the file at the path defines module %s. Did you mean `include %s as %s`?", + provided_name, + actual_name, + actual_name, + provided_name, + ) | Cannot_eliminate_dependency(mty) => fprintf( ppf, diff --git a/compiler/src/typed/typemod.rei b/compiler/src/typed/typemod.rei index 720a81f690..c0820d6f73 100644 --- a/compiler/src/typed/typemod.rei +++ b/compiler/src/typed/typemod.rei @@ -5,6 +5,7 @@ open Typedtree; type error = | Cannot_apply(module_type) | Not_included(list(Includemod.error)) + | Include_module_name_mismatch(string, string) | Cannot_eliminate_dependency(module_type) | Signature_expected | Structure_expected(module_type) diff --git a/compiler/test/grainfmt/application.expected.gr b/compiler/test/grainfmt/application.expected.gr index 84fef09577..13ff2e6a07 100644 --- a/compiler/test/grainfmt/application.expected.gr +++ b/compiler/test/grainfmt/application.expected.gr @@ -1,8 +1,8 @@ module Application -include "array" -include "option" -include "map" +from "array" include Array +from "option" include Option +from "map" include Map let data = [>] diff --git a/compiler/test/grainfmt/application.input.gr b/compiler/test/grainfmt/application.input.gr index 2d1a98f5f0..2124f8d5ff 100644 --- a/compiler/test/grainfmt/application.input.gr +++ b/compiler/test/grainfmt/application.input.gr @@ -1,8 +1,8 @@ module Application -include "array" -include "option" -include "map" +from "array" include Array +from "option" include Option +from "map" include Map let data = [>] diff --git a/compiler/test/grainfmt/arrays.expected.gr b/compiler/test/grainfmt/arrays.expected.gr index f92102120c..b5e0bfc689 100644 --- a/compiler/test/grainfmt/arrays.expected.gr +++ b/compiler/test/grainfmt/arrays.expected.gr @@ -1,6 +1,6 @@ module Arrays -include "array" +from "array" include Array let empty = [>] diff --git a/compiler/test/grainfmt/arrays.input.gr b/compiler/test/grainfmt/arrays.input.gr index 94ae777cbc..485b19aafe 100644 --- a/compiler/test/grainfmt/arrays.input.gr +++ b/compiler/test/grainfmt/arrays.input.gr @@ -1,6 +1,6 @@ module Arrays -include "array" +from "array" include Array let empty = [>] diff --git a/compiler/test/grainfmt/comments.expected.gr b/compiler/test/grainfmt/comments.expected.gr index 2ceeb473bc..c56da3d89b 100644 --- a/compiler/test/grainfmt/comments.expected.gr +++ b/compiler/test/grainfmt/comments.expected.gr @@ -571,8 +571,8 @@ type /* type */ Foo /* Foo primitive /* prim */ foo /* foo */ = /* hello */ "@hello" -include /* include */ "foo" -include /* include */ "foo" /* foo */ as /* alias */ Foo +from /* from */ "foo" /* foo */ include /* include */ Foo +from /* from */ "foo" /* foo */ include /* include */ Foo /* as */ as /* alias */ Foo module /* module */ Foo /* Foo */ { foo; /* foo */ bar diff --git a/compiler/test/grainfmt/constraints.expected.gr b/compiler/test/grainfmt/constraints.expected.gr index ac9acee09c..6f307c7fef 100644 --- a/compiler/test/grainfmt/constraints.expected.gr +++ b/compiler/test/grainfmt/constraints.expected.gr @@ -1,6 +1,6 @@ module Constraints -include "list" +from "list" include List let test = test => { // Comments List.forEach(i => { diff --git a/compiler/test/grainfmt/constraints.input.gr b/compiler/test/grainfmt/constraints.input.gr index adb2dda1e6..6f307c7fef 100644 --- a/compiler/test/grainfmt/constraints.input.gr +++ b/compiler/test/grainfmt/constraints.input.gr @@ -1,5 +1,6 @@ module Constraints -include "list" + +from "list" include List let test = test => { // Comments List.forEach(i => { diff --git a/compiler/test/grainfmt/includes.expected.gr b/compiler/test/grainfmt/includes.expected.gr index 95b52e6140..67cd06f100 100644 --- a/compiler/test/grainfmt/includes.expected.gr +++ b/compiler/test/grainfmt/includes.expected.gr @@ -1,12 +1,12 @@ module Includes -include "runtime/unsafe/memory" -include "runtime/unsafe/tags" -include "list" -include "option" as Opt -include "option" as Opt -include /* special include */ "array" -include "array" as /* special include */ Foo +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "list" include List +from "option" include Option as Opt +from "option" include Option as Opt +from /* special include */ "array" include Array +from "array" include Array as /* special include */ Foo use List.{ length, map, forEach as each } use Opt.{ module MutableOpt, @@ -24,13 +24,13 @@ use Opt.{ exception Exc2, /* comment9 */ } -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ add as (+), mul as (*), xor as (^), shl as (<<) } provide foreign wasm storage_read: (WasmI64, WasmI64, WasmI64) => WasmI64 as storageRead from "env" -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ eq, // comment1 // comment 3 diff --git a/compiler/test/grainfmt/includes.input.gr b/compiler/test/grainfmt/includes.input.gr index 7e9e434756..58e187586e 100644 --- a/compiler/test/grainfmt/includes.input.gr +++ b/compiler/test/grainfmt/includes.input.gr @@ -1,18 +1,18 @@ module Includes -include "runtime/unsafe/memory" -include "runtime/unsafe/tags" -include "list" -include "option" as Opt -include "option" as +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "list" include List +from "option" include Option as Opt +from "option" include Option as Opt -include /* special include */ "array" -include "array" as /* special include */ Foo +from /* special include */ "array" include Array +from "array" include Array as /* special include */ Foo use List.{ length, map, forEach as each } use Opt.{ module MutableOpt, module ImmutableOpt as Imm, type Opt, type Opt as OptAlias } use Opt.{ module MutableOpt, /* comment1 */ module ImmutableOpt /* comment2 */ as /* comment3 */ Imm /* comment4 */, /* comment5 */ type /* comment6 */ Opt, type Opt as /* comment7 */ OptAlias, exception Exc as /* comment8 */ E, exception Exc2 /* comment9 */ } -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ add as (+), mul as (*), @@ -23,7 +23,7 @@ use WasmI32.{ provide foreign wasm storage_read: (WasmI64, WasmI64, WasmI64) => WasmI64 as storageRead from "env" -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ eq, // comment1 // comment 3 diff --git a/compiler/test/grainfmt/matches.expected.gr b/compiler/test/grainfmt/matches.expected.gr index e664720c1f..1867bd377e 100644 --- a/compiler/test/grainfmt/matches.expected.gr +++ b/compiler/test/grainfmt/matches.expected.gr @@ -1,6 +1,6 @@ module Matches -include "list" +from "list" include List record Queue { forwards: List, diff --git a/compiler/test/grainfmt/matches.input.gr b/compiler/test/grainfmt/matches.input.gr index 3d070f6382..9013c33896 100644 --- a/compiler/test/grainfmt/matches.input.gr +++ b/compiler/test/grainfmt/matches.input.gr @@ -1,6 +1,6 @@ module Matches -include "list" +from "list" include List record Queue { forwards: List, backwards: List } diff --git a/compiler/test/grainfmt/operators.expected.gr b/compiler/test/grainfmt/operators.expected.gr index 6daf983e78..a897b10b91 100644 --- a/compiler/test/grainfmt/operators.expected.gr +++ b/compiler/test/grainfmt/operators.expected.gr @@ -1,6 +1,6 @@ module Operators -include "list" +from "list" include List let myList = [] diff --git a/compiler/test/grainfmt/operators.input.gr b/compiler/test/grainfmt/operators.input.gr index 6daf983e78..a897b10b91 100644 --- a/compiler/test/grainfmt/operators.input.gr +++ b/compiler/test/grainfmt/operators.input.gr @@ -1,6 +1,6 @@ module Operators -include "list" +from "list" include List let myList = [] diff --git a/compiler/test/grainfmt/patterns.expected.gr b/compiler/test/grainfmt/patterns.expected.gr index 70fd6ccaa8..414fffea95 100644 --- a/compiler/test/grainfmt/patterns.expected.gr +++ b/compiler/test/grainfmt/patterns.expected.gr @@ -1,7 +1,7 @@ module Patterns -include "option" -include "list" +from "option" include Option +from "list" include List let user = Some("Bob") diff --git a/compiler/test/grainfmt/patterns.input.gr b/compiler/test/grainfmt/patterns.input.gr index 3f72cd3dab..5d675105ab 100644 --- a/compiler/test/grainfmt/patterns.input.gr +++ b/compiler/test/grainfmt/patterns.input.gr @@ -1,7 +1,7 @@ module Patterns -include "option" -include "list" +from "option" include Option +from "list" include List let user = Some("Bob") diff --git a/compiler/test/grainfmt/rationals.expected.gr b/compiler/test/grainfmt/rationals.expected.gr index ef51899266..7103e84477 100644 --- a/compiler/test/grainfmt/rationals.expected.gr +++ b/compiler/test/grainfmt/rationals.expected.gr @@ -1,6 +1,6 @@ module Rationals -include "int32" +from "int32" include Int32 let a = Int32.toNumber(3l) * (2/3) diff --git a/compiler/test/grainfmt/rationals.input.gr b/compiler/test/grainfmt/rationals.input.gr index af3b439c23..b7016d77cb 100644 --- a/compiler/test/grainfmt/rationals.input.gr +++ b/compiler/test/grainfmt/rationals.input.gr @@ -1,6 +1,6 @@ module Rationals -include "int32" +from "int32" include Int32 let a = Int32.toNumber(3l) * (2/3) diff --git a/compiler/test/grainfmt/records.expected.gr b/compiler/test/grainfmt/records.expected.gr index ffb5c4b036..5dc484337a 100644 --- a/compiler/test/grainfmt/records.expected.gr +++ b/compiler/test/grainfmt/records.expected.gr @@ -1,6 +1,6 @@ module Records -include "set" +from "set" include Set record Rec { foo: Number, diff --git a/compiler/test/grainfmt/records.input.gr b/compiler/test/grainfmt/records.input.gr index 690486f3be..fd0cb205f2 100644 --- a/compiler/test/grainfmt/records.input.gr +++ b/compiler/test/grainfmt/records.input.gr @@ -1,6 +1,6 @@ module Records -include "set" +from "set" include Set record Rec {foo: Number, bar: Number} let x = {foo: 4, bar: 9} diff --git a/compiler/test/grainfmt/strings.expected.gr b/compiler/test/grainfmt/strings.expected.gr index d8eb33a16b..355ccd68af 100644 --- a/compiler/test/grainfmt/strings.expected.gr +++ b/compiler/test/grainfmt/strings.expected.gr @@ -1,6 +1,6 @@ module Strings -include "string" +from "string" include String let newline = "\n" diff --git a/compiler/test/grainfmt/strings.input.gr b/compiler/test/grainfmt/strings.input.gr index d8eb33a16b..355ccd68af 100644 --- a/compiler/test/grainfmt/strings.input.gr +++ b/compiler/test/grainfmt/strings.input.gr @@ -1,6 +1,6 @@ module Strings -include "string" +from "string" include String let newline = "\n" diff --git a/compiler/test/grainfmt/values.expected.gr b/compiler/test/grainfmt/values.expected.gr index 16d98cb00a..5a207ab585 100644 --- a/compiler/test/grainfmt/values.expected.gr +++ b/compiler/test/grainfmt/values.expected.gr @@ -1,15 +1,15 @@ module Values -include "int32" -include "int64" -include "float32" -include "float64" -include "bytes" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" - -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" +from "int32" include Int32 +from "int64" include Int64 +from "float32" include Float32 +from "float64" include Float64 +from "bytes" include Bytes +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 + +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 let char = 'a' diff --git a/compiler/test/grainfmt/values.input.gr b/compiler/test/grainfmt/values.input.gr index 81a773fd4f..58017a909c 100644 --- a/compiler/test/grainfmt/values.input.gr +++ b/compiler/test/grainfmt/values.input.gr @@ -1,15 +1,15 @@ module Values -include "int32" -include "int64" -include "float32" -include "float64" -include "bytes" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" - -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" +from "int32" include Int32 +from "int64" include Int64 +from "float32" include Float32 +from "float64" include Float64 +from "bytes" include Bytes +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 + +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 let char = 'a' diff --git a/compiler/test/input/brokenIncludes/broken.gr b/compiler/test/input/brokenIncludes/broken.gr index a0d50a7bf7..dfd456e20c 100644 --- a/compiler/test/input/brokenIncludes/broken.gr +++ b/compiler/test/input/brokenIncludes/broken.gr @@ -1,6 +1,6 @@ module Broken -include "number" -include "./foo" +from "number" include Number +from "./foo" include Foo provide let min = Number.min diff --git a/compiler/test/input/brokenIncludes/main.gr b/compiler/test/input/brokenIncludes/main.gr index f292286fa4..3fab86ca61 100644 --- a/compiler/test/input/brokenIncludes/main.gr +++ b/compiler/test/input/brokenIncludes/main.gr @@ -1,5 +1,5 @@ module Main -include "./broken" +from "./broken" include Broken print(Broken.min(2, 3)) diff --git a/compiler/test/input/customOperator.gr b/compiler/test/input/customOperator.gr index bb1250d057..e6869e4b57 100644 --- a/compiler/test/input/customOperator.gr +++ b/compiler/test/input/customOperator.gr @@ -1,6 +1,6 @@ module CustomOperator -include "result" +from "result" include Result let (>>=) = (a, b) => Result.flatMap(b, a) diff --git a/compiler/test/input/earlyReturn.gr b/compiler/test/input/earlyReturn.gr index a4eff4da89..dc1833cbbd 100644 --- a/compiler/test/input/earlyReturn.gr +++ b/compiler/test/input/earlyReturn.gr @@ -1,6 +1,6 @@ module EarlyReturn -include "array" +from "array" include Array let findFour = arr => { for (let mut i = 0; i < Array.length(arr); i += 1) { diff --git a/compiler/test/input/letMutForLoop.gr b/compiler/test/input/letMutForLoop.gr index fe06d321b6..4ad92a2dc5 100644 --- a/compiler/test/input/letMutForLoop.gr +++ b/compiler/test/input/letMutForLoop.gr @@ -1,7 +1,7 @@ module LetMutForLoop -include "runtime/unsafe/wasmi64" -include "runtime/debugPrint" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/debugPrint" include DebugPrint @unsafe let foo = () => { diff --git a/compiler/test/input/list.gr b/compiler/test/input/list.gr index 5225a96187..442bc67f63 100644 --- a/compiler/test/input/list.gr +++ b/compiler/test/input/list.gr @@ -1,6 +1,6 @@ module List -include "list" +from "list" include List use List.* print("OK") diff --git a/compiler/test/input/long_lists.gr b/compiler/test/input/long_lists.gr index 34d8ef690f..fcc53731cb 100644 --- a/compiler/test/input/long_lists.gr +++ b/compiler/test/input/long_lists.gr @@ -1,6 +1,6 @@ module LongLists -include "list" +from "list" include List use List.* let rec make_list = (x, n) => { diff --git a/compiler/test/input/mallocTight.gr b/compiler/test/input/mallocTight.gr index 43229e9e0a..cc8616ab79 100644 --- a/compiler/test/input/mallocTight.gr +++ b/compiler/test/input/mallocTight.gr @@ -1,8 +1,8 @@ /* grainc-flags --compilation-mode=runtime */ module MallocTight -include "runtime/malloc" -include "runtime/unsafe/wasmi32" +from "runtime/malloc" include Malloc +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (*), (==), (!=) } primitive assert = "@assert" diff --git a/compiler/test/input/memoryBase/asserts.gr b/compiler/test/input/memoryBase/asserts.gr index 3db888aad7..dfe4d4abd4 100644 --- a/compiler/test/input/memoryBase/asserts.gr +++ b/compiler/test/input/memoryBase/asserts.gr @@ -1,7 +1,7 @@ /* grainc-flags --memory-base 0x110000 */ module Asserts -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 @unsafe primitive heapStart = "@heap.start" diff --git a/compiler/test/input/memoryGrow.gr b/compiler/test/input/memoryGrow.gr index 2039ffc6fd..1897f5edd2 100644 --- a/compiler/test/input/memoryGrow.gr +++ b/compiler/test/input/memoryGrow.gr @@ -1,6 +1,6 @@ module MemoryGrow -include "array" +from "array" include Array let array = Array.init(1_000_000, i => (i, i + 1)) diff --git a/compiler/test/input/mixedPatternMatching.gr b/compiler/test/input/mixedPatternMatching.gr index e23e133df5..cfbab6fa16 100644 --- a/compiler/test/input/mixedPatternMatching.gr +++ b/compiler/test/input/mixedPatternMatching.gr @@ -1,6 +1,6 @@ module MixedPatternMatching -include "list" +from "list" include List use List.* provide record Rec { diff --git a/compiler/test/input/modules/provideIncludedModule.gr b/compiler/test/input/modules/provideIncludedModule.gr index d601a46d5c..6550abafa7 100644 --- a/compiler/test/input/modules/provideIncludedModule.gr +++ b/compiler/test/input/modules/provideIncludedModule.gr @@ -1,7 +1,7 @@ module ProvideIncludedModule -include "option" as Option -include "array" as Array +from "option" include Option +from "array" include Array provide { module Option as Smoption } diff --git a/compiler/test/input/nestedModules.gr b/compiler/test/input/nestedModules.gr index 930fe8178b..6928457c49 100644 --- a/compiler/test/input/nestedModules.gr +++ b/compiler/test/input/nestedModules.gr @@ -1,7 +1,7 @@ module NestedModules -include "list" as List -include "./modules/provideIncludedModule" as Deep +from "list" include List +from "./modules/provideIncludedModule" include ProvideIncludedModule as Deep module Foo { provide let foo = "hello from foo" diff --git a/compiler/test/input/relativeInclude1.gr b/compiler/test/input/relativeInclude1.gr index c364c8a3c8..c47d5d2d59 100644 --- a/compiler/test/input/relativeInclude1.gr +++ b/compiler/test/input/relativeInclude1.gr @@ -1,5 +1,5 @@ module RelativeInclude1 -include "../test-libs/provideAll" +from "../test-libs/provideAll" include ProvideAll use ProvideAll.* x diff --git a/compiler/test/input/relativeInclude2.gr b/compiler/test/input/relativeInclude2.gr index a7c9a77ec3..bb97a180e2 100644 --- a/compiler/test/input/relativeInclude2.gr +++ b/compiler/test/input/relativeInclude2.gr @@ -1,5 +1,5 @@ module RelativeImport2 -include "../../test/test-libs/provideAll" +from "../../test/test-libs/provideAll" include ProvideAll use ProvideAll.* x diff --git a/compiler/test/input/relativeInclude3.gr b/compiler/test/input/relativeInclude3.gr index a3f6120f29..1fffe788a9 100644 --- a/compiler/test/input/relativeInclude3.gr +++ b/compiler/test/input/relativeInclude3.gr @@ -1,5 +1,5 @@ module RelativeImport3 -include "nested/nested" +from "nested/nested" include Nested use Nested.* j diff --git a/compiler/test/input/relativeIncludeLinking.gr b/compiler/test/input/relativeIncludeLinking.gr index b5012c8d97..87b04faab2 100644 --- a/compiler/test/input/relativeIncludeLinking.gr +++ b/compiler/test/input/relativeIncludeLinking.gr @@ -1,7 +1,7 @@ module RelativeIncludeLinking -include "./relativeIncludeLinking/a" -include "./relativeIncludeLinking/mutExport" +from "./relativeIncludeLinking/a" include A +from "./relativeIncludeLinking/mutExport" include MutExport MutExport.x := unbox(MutExport.x) + 1 diff --git a/compiler/test/input/relativeIncludeLinking/a.gr b/compiler/test/input/relativeIncludeLinking/a.gr index 6c2d258a7e..4c49166cf1 100644 --- a/compiler/test/input/relativeIncludeLinking/a.gr +++ b/compiler/test/input/relativeIncludeLinking/a.gr @@ -1,6 +1,6 @@ module A -include "./mutExport" +from "./mutExport" include MutExport MutExport.x := unbox(MutExport.x) + 1 diff --git a/compiler/test/input/relativeIncludes/bar/bar.gr b/compiler/test/input/relativeIncludes/bar/bar.gr index d9dc20d28f..812d9eb91b 100644 --- a/compiler/test/input/relativeIncludes/bar/bar.gr +++ b/compiler/test/input/relativeIncludes/bar/bar.gr @@ -1,6 +1,6 @@ module Bar -include "./baz" +from "./baz" include Baz use Baz.{ baz } provide let bar = n => baz(n) * 3 diff --git a/compiler/test/input/relativeIncludes/bar/baz.gr b/compiler/test/input/relativeIncludes/bar/baz.gr index cb4b5e87bb..b8e27db52d 100644 --- a/compiler/test/input/relativeIncludes/bar/baz.gr +++ b/compiler/test/input/relativeIncludes/bar/baz.gr @@ -1,5 +1,5 @@ module Baz -include "../quux/quux" +from "../quux/quux" include Quux use Quux.{ quux } provide let baz = n => quux(n) + 1 diff --git a/compiler/test/input/relativeIncludes/foo.gr b/compiler/test/input/relativeIncludes/foo.gr index 1e115def57..46dc8e089e 100644 --- a/compiler/test/input/relativeIncludes/foo.gr +++ b/compiler/test/input/relativeIncludes/foo.gr @@ -1,6 +1,6 @@ module Foo -include "./bar/bar" +from "./bar/bar" include Bar use Bar.{ bar } print(bar(2)) diff --git a/compiler/test/input/unsafeWasmGlobals.gr b/compiler/test/input/unsafeWasmGlobals.gr index d75188e641..b044b95356 100644 --- a/compiler/test/input/unsafeWasmGlobals.gr +++ b/compiler/test/input/unsafeWasmGlobals.gr @@ -1,9 +1,9 @@ /* grainc-flags --no-gc */ module UnsafeWasmGlobals -include "runtime/debugPrint" +from "runtime/debugPrint" include DebugPrint -include "unsafeWasmGlobalsExports" +from "unsafeWasmGlobalsExports" include UnsafeWasmGlobalsExports use UnsafeWasmGlobalsExports.{ _I32_VAL, _I64_VAL, _F32_VAL, _F64_VAL } DebugPrint.printI32(_I32_VAL) diff --git a/compiler/test/runtime/numbers.test.gr b/compiler/test/runtime/numbers.test.gr index 1ccd5c66a3..5218263849 100644 --- a/compiler/test/runtime/numbers.test.gr +++ b/compiler/test/runtime/numbers.test.gr @@ -1,6 +1,6 @@ module NumberTest -include "runtime/numbers" +from "runtime/numbers" include Numbers // Simple isNaN let isNaN = x => x != x diff --git a/compiler/test/stdlib/array.test.gr b/compiler/test/stdlib/array.test.gr index 646fd01ef7..9757f120f8 100644 --- a/compiler/test/stdlib/array.test.gr +++ b/compiler/test/stdlib/array.test.gr @@ -1,9 +1,9 @@ module ArrayTest -include "list" -include "array" -include "string" -include "range" +from "list" include List +from "array" include Array +from "string" include String +from "range" include Range let arr = [> 1, 2, 3] diff --git a/compiler/test/stdlib/bigint.test.gr b/compiler/test/stdlib/bigint.test.gr index b42c0beefe..139b33ec30 100644 --- a/compiler/test/stdlib/bigint.test.gr +++ b/compiler/test/stdlib/bigint.test.gr @@ -1,8 +1,8 @@ module BigintTest -include "list" -include "runtime/wasi" -include "bigint" +from "list" include List +from "runtime/wasi" include Wasi +from "bigint" include BigInt let eq = (==) diff --git a/compiler/test/stdlib/buffer.test.gr b/compiler/test/stdlib/buffer.test.gr index 5597a0541c..4ec9106a99 100644 --- a/compiler/test/stdlib/buffer.test.gr +++ b/compiler/test/stdlib/buffer.test.gr @@ -1,11 +1,11 @@ module BufferTest -include "array" -include "string" -include "buffer" -include "bytes" -include "int32" -include "char" +from "array" include Array +from "string" include String +from "buffer" include Buffer +from "bytes" include Bytes +from "int32" include Int32 +from "char" include Char // it should have 0 length when buffer is created assert Buffer.length(Buffer.make(0)) == 0 diff --git a/compiler/test/stdlib/bytes.test.gr b/compiler/test/stdlib/bytes.test.gr index b137d4f264..6461c2126b 100644 --- a/compiler/test/stdlib/bytes.test.gr +++ b/compiler/test/stdlib/bytes.test.gr @@ -1,11 +1,11 @@ module BytesTest -include "bytes" -include "int8" -include "uint8" -include "int32" -include "array" -include "string" +from "bytes" include Bytes +from "int8" include Int8 +from "uint8" include Uint8 +from "int32" include Int32 +from "array" include Array +from "string" include String // Bytes.empty assert Bytes.empty == Bytes.empty diff --git a/compiler/test/stdlib/char.test.gr b/compiler/test/stdlib/char.test.gr index b4c626bc21..e2e55645af 100644 --- a/compiler/test/stdlib/char.test.gr +++ b/compiler/test/stdlib/char.test.gr @@ -1,8 +1,8 @@ module CharTest -include "char" -include "string" -include "array" +from "char" include Char +from "string" include String +from "array" include Array // isValid diff --git a/compiler/test/stdlib/float32.test.gr b/compiler/test/stdlib/float32.test.gr index f8f7625603..87742c5d46 100644 --- a/compiler/test/stdlib/float32.test.gr +++ b/compiler/test/stdlib/float32.test.gr @@ -1,6 +1,6 @@ module Float32Test -include "float32" +from "float32" include Float32 use Float32.* use Pervasives.{ (-) as numberSub } diff --git a/compiler/test/stdlib/float64.test.gr b/compiler/test/stdlib/float64.test.gr index ee02c600f2..34232dde6a 100644 --- a/compiler/test/stdlib/float64.test.gr +++ b/compiler/test/stdlib/float64.test.gr @@ -1,6 +1,6 @@ module Float64Test -include "float64" +from "float64" include Float64 use Float64.* // Constants Tests diff --git a/compiler/test/stdlib/hash.test.gr b/compiler/test/stdlib/hash.test.gr index d3ae81dabc..b8e4d56982 100644 --- a/compiler/test/stdlib/hash.test.gr +++ b/compiler/test/stdlib/hash.test.gr @@ -2,11 +2,11 @@ module HashTest // Sanity tests for generic hashing. -include "hash" -include "list" -include "array" -include "string" -include "bytes" +from "hash" include Hash +from "list" include List +from "array" include Array +from "string" include String +from "bytes" include Bytes let uniq = list => { let mut itemsSeen = [] diff --git a/compiler/test/stdlib/int16.test.gr b/compiler/test/stdlib/int16.test.gr index 83c15b4cc2..f55ea5fab1 100644 --- a/compiler/test/stdlib/int16.test.gr +++ b/compiler/test/stdlib/int16.test.gr @@ -1,6 +1,6 @@ module Int16Test -include "int16" +from "int16" include Int16 use Int16.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/int32.test.gr b/compiler/test/stdlib/int32.test.gr index 148acb0eda..de1af5175f 100644 --- a/compiler/test/stdlib/int32.test.gr +++ b/compiler/test/stdlib/int32.test.gr @@ -1,6 +1,6 @@ module Int32Test -include "int32" +from "int32" include Int32 use Int32.* use Pervasives.{ (==) } diff --git a/compiler/test/stdlib/int64.test.gr b/compiler/test/stdlib/int64.test.gr index 3186a5c658..81d5ea01f6 100644 --- a/compiler/test/stdlib/int64.test.gr +++ b/compiler/test/stdlib/int64.test.gr @@ -1,6 +1,6 @@ module Int64Test -include "int64" +from "int64" include Int64 use Int64.* // Suppress warnings about using `fromNumber` on constants, since that's what we want to test. diff --git a/compiler/test/stdlib/int8.test.gr b/compiler/test/stdlib/int8.test.gr index 059f66c99c..654693a562 100644 --- a/compiler/test/stdlib/int8.test.gr +++ b/compiler/test/stdlib/int8.test.gr @@ -1,6 +1,6 @@ module Int8Test -include "int8" +from "int8" include Int8 use Int8.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/list.test.gr b/compiler/test/stdlib/list.test.gr index a23a431781..5b24ea1cf7 100644 --- a/compiler/test/stdlib/list.test.gr +++ b/compiler/test/stdlib/list.test.gr @@ -1,8 +1,8 @@ module ListTest -include "list" +from "list" include List use List.* -include "string" +from "string" include String let list = [1, 2, 3] diff --git a/compiler/test/stdlib/map.test.gr b/compiler/test/stdlib/map.test.gr index 9cf9852843..f710f1176f 100644 --- a/compiler/test/stdlib/map.test.gr +++ b/compiler/test/stdlib/map.test.gr @@ -1,8 +1,8 @@ module MapTest -include "map" -include "list" -include "array" +from "map" include Map +from "list" include List +from "array" include Array // Data types used in multiple tests enum Resource { diff --git a/compiler/test/stdlib/marshal.test.gr b/compiler/test/stdlib/marshal.test.gr index bc5242acbf..1c3488f02d 100644 --- a/compiler/test/stdlib/marshal.test.gr +++ b/compiler/test/stdlib/marshal.test.gr @@ -1,9 +1,9 @@ module MarshalTest -include "marshal" +from "marshal" include Marshal use Marshal.* -include "bytes" -include "result" +from "bytes" include Bytes +from "result" include Result let roundtripOk = value => unmarshal(marshal(value)) == Ok(value) diff --git a/compiler/test/stdlib/number.test.gr b/compiler/test/stdlib/number.test.gr index 693b1e9d11..2737f570b2 100644 --- a/compiler/test/stdlib/number.test.gr +++ b/compiler/test/stdlib/number.test.gr @@ -1,11 +1,11 @@ module NumberTest -include "number" +from "number" include Number use Number.{ (+), (-), (*), (/) as div, (**) } -include "result" -include "int32" -include "int64" -include "bigint" as BI +from "result" include Result +from "int32" include Int32 +from "int64" include Int64 +from "bigint" include BigInt as BI // Constants Test diff --git a/compiler/test/stdlib/option.test.gr b/compiler/test/stdlib/option.test.gr index 69b42fcf52..845eb92a24 100644 --- a/compiler/test/stdlib/option.test.gr +++ b/compiler/test/stdlib/option.test.gr @@ -1,7 +1,7 @@ module OptionTest -include "option" -include "string" +from "option" include Option +from "string" include String // Option.isSome diff --git a/compiler/test/stdlib/path.test.gr b/compiler/test/stdlib/path.test.gr index ea7b0cead9..fed41b1f42 100644 --- a/compiler/test/stdlib/path.test.gr +++ b/compiler/test/stdlib/path.test.gr @@ -1,9 +1,9 @@ module PathTest -include "path" -include "result" -include "option" -include "list" +from "path" include Path +from "result" include Result +from "option" include Option +from "list" include List let fs = Path.fromString diff --git a/compiler/test/stdlib/priorityqueue.test.gr b/compiler/test/stdlib/priorityqueue.test.gr index 9d0ccb265f..77f142310f 100644 --- a/compiler/test/stdlib/priorityqueue.test.gr +++ b/compiler/test/stdlib/priorityqueue.test.gr @@ -1,8 +1,8 @@ module PriorityQueueTest -include "priorityqueue" -include "list" -include "array" +from "priorityqueue" include PriorityQueue +from "list" include List +from "array" include Array // formatter-ignore let lotsOfVals = [> diff --git a/compiler/test/stdlib/queue.test.gr b/compiler/test/stdlib/queue.test.gr index e94d77f625..d31a914828 100644 --- a/compiler/test/stdlib/queue.test.gr +++ b/compiler/test/stdlib/queue.test.gr @@ -1,7 +1,7 @@ module QueueTest -include "queue" -include "list" +from "queue" include Queue +from "list" include List // Mutable queue tests diff --git a/compiler/test/stdlib/random.test.gr b/compiler/test/stdlib/random.test.gr index 5682b43206..41fe66bd2c 100644 --- a/compiler/test/stdlib/random.test.gr +++ b/compiler/test/stdlib/random.test.gr @@ -1,6 +1,6 @@ module RandomTest -include "random" +from "random" include Random let rng1 = Random.make(0xf00uL) let rng2 = Random.make(0xf00uL) diff --git a/compiler/test/stdlib/range.test.gr b/compiler/test/stdlib/range.test.gr index e972a0c815..891778ac26 100644 --- a/compiler/test/stdlib/range.test.gr +++ b/compiler/test/stdlib/range.test.gr @@ -1,6 +1,6 @@ module RangeTest -include "range" +from "range" include Range let exclusiveAscendingRange = { rangeStart: 1, rangeEnd: 5 } let exclusiveDescendingRange = { rangeStart: 5, rangeEnd: 1 } diff --git a/compiler/test/stdlib/rational.test.gr b/compiler/test/stdlib/rational.test.gr index c1e102683f..708805f168 100644 --- a/compiler/test/stdlib/rational.test.gr +++ b/compiler/test/stdlib/rational.test.gr @@ -1,6 +1,6 @@ module RationalTest -include "rational" +from "rational" include Rational use Rational.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/regex.test.gr b/compiler/test/stdlib/regex.test.gr index 5539f9002b..605e06eccf 100644 --- a/compiler/test/stdlib/regex.test.gr +++ b/compiler/test/stdlib/regex.test.gr @@ -1,10 +1,10 @@ module RegexTest -include "array" -include "list" -include "option" -include "result" -include "regex" +from "array" include Array +from "list" include List +from "option" include Option +from "result" include Result +from "regex" include Regex use Regex.{ make, find, diff --git a/compiler/test/stdlib/result.test.gr b/compiler/test/stdlib/result.test.gr index 1b84fedb60..fae24758f2 100644 --- a/compiler/test/stdlib/result.test.gr +++ b/compiler/test/stdlib/result.test.gr @@ -1,6 +1,6 @@ module ResultTest -include "result" +from "result" include Result // isOk assert Result.isOk(Ok(1)) == true diff --git a/compiler/test/stdlib/set.test.gr b/compiler/test/stdlib/set.test.gr index 6625aa9f41..ff73fd7373 100644 --- a/compiler/test/stdlib/set.test.gr +++ b/compiler/test/stdlib/set.test.gr @@ -1,8 +1,8 @@ module SetTest -include "set" -include "list" -include "array" +from "set" include Set +from "list" include List +from "array" include Array // Data types used in multiple tests enum Resource { diff --git a/compiler/test/stdlib/stack.test.gr b/compiler/test/stdlib/stack.test.gr index 6cc290eb7a..8f56a3ae99 100644 --- a/compiler/test/stdlib/stack.test.gr +++ b/compiler/test/stdlib/stack.test.gr @@ -1,6 +1,6 @@ module StackTest -include "stack" +from "stack" include Stack // Mutable stack tests diff --git a/compiler/test/stdlib/string.test.gr b/compiler/test/stdlib/string.test.gr index 35cdc80318..df0bc8e3fa 100644 --- a/compiler/test/stdlib/string.test.gr +++ b/compiler/test/stdlib/string.test.gr @@ -1,9 +1,9 @@ module StringTest -include "string" -include "char" -include "array" -include "bytes" +from "string" include String +from "char" include Char +from "array" include Array +from "bytes" include Bytes let fox = "The quick brown fox jumps over the lazy dog." let emojis = diff --git a/compiler/test/stdlib/sys.file.test.gr b/compiler/test/stdlib/sys.file.test.gr index 028c1fa866..93668b2926 100644 --- a/compiler/test/stdlib/sys.file.test.gr +++ b/compiler/test/stdlib/sys.file.test.gr @@ -1,8 +1,8 @@ module FileTest -include "sys/file" as Fs -include "bytes" -include "result" +from "sys/file" include File as Fs +from "bytes" include Bytes +from "result" include Result // fdRead let foo = Result.unwrap( diff --git a/compiler/test/stdlib/sys.process.test.gr b/compiler/test/stdlib/sys.process.test.gr index 88013e0888..dadc3372ed 100644 --- a/compiler/test/stdlib/sys.process.test.gr +++ b/compiler/test/stdlib/sys.process.test.gr @@ -1,7 +1,7 @@ module ProcessTest -include "array" -include "sys/process" +from "array" include Array +from "sys/process" include Process // Just a smoke test match (Process.argv()) { diff --git a/compiler/test/stdlib/sys.random.test.gr b/compiler/test/stdlib/sys.random.test.gr index 1d6c38a6e0..2b5af8ed39 100644 --- a/compiler/test/stdlib/sys.random.test.gr +++ b/compiler/test/stdlib/sys.random.test.gr @@ -1,6 +1,6 @@ module RandomTest -include "sys/random" +from "sys/random" include Random // Just smoke tests, there's a miniscule chance these could fail diff --git a/compiler/test/stdlib/sys.time.test.gr b/compiler/test/stdlib/sys.time.test.gr index 632ca6ad9a..321d69c12e 100644 --- a/compiler/test/stdlib/sys.time.test.gr +++ b/compiler/test/stdlib/sys.time.test.gr @@ -1,8 +1,8 @@ module TimeTest -include "int64" +from "int64" include Int64 use Int64.{ (<), (<=) } -include "sys/time" +from "sys/time" include Time let mt1 = Time.monotonicTime() let mt2 = Time.monotonicTime() diff --git a/compiler/test/stdlib/uint16.test.gr b/compiler/test/stdlib/uint16.test.gr index 5abeed99bb..e9d72fa7fc 100644 --- a/compiler/test/stdlib/uint16.test.gr +++ b/compiler/test/stdlib/uint16.test.gr @@ -1,6 +1,6 @@ module Uint16Test -include "uint16" +from "uint16" include Uint16 use Uint16.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/uint32.test.gr b/compiler/test/stdlib/uint32.test.gr index 993a69f8bd..77bc009ba7 100644 --- a/compiler/test/stdlib/uint32.test.gr +++ b/compiler/test/stdlib/uint32.test.gr @@ -1,6 +1,6 @@ module Uint32Test -include "uint32" +from "uint32" include Uint32 use Uint32.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/uint64.test.gr b/compiler/test/stdlib/uint64.test.gr index 8bc4ed6e25..b83cb02a0d 100644 --- a/compiler/test/stdlib/uint64.test.gr +++ b/compiler/test/stdlib/uint64.test.gr @@ -1,6 +1,6 @@ module Uint64Test -include "uint64" +from "uint64" include Uint64 use Uint64.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/uint8.test.gr b/compiler/test/stdlib/uint8.test.gr index 1f6d60f164..4d1eae05ed 100644 --- a/compiler/test/stdlib/uint8.test.gr +++ b/compiler/test/stdlib/uint8.test.gr @@ -1,6 +1,6 @@ module Uint8Test -include "uint8" +from "uint8" include Uint8 use Uint8.{ fromNumber, toNumber, diff --git a/compiler/test/stdlib/wasmf32.test.gr b/compiler/test/stdlib/wasmf32.test.gr index 8b18db3e01..3b8b883bb4 100644 --- a/compiler/test/stdlib/wasmf32.test.gr +++ b/compiler/test/stdlib/wasmf32.test.gr @@ -1,7 +1,7 @@ module WasmF32Test -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/conv" +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/conv" include Conv @unsafe let test = () => { diff --git a/compiler/test/stdlib/wasmf64.test.gr b/compiler/test/stdlib/wasmf64.test.gr index 536c179332..5e9307e87d 100644 --- a/compiler/test/stdlib/wasmf64.test.gr +++ b/compiler/test/stdlib/wasmf64.test.gr @@ -1,7 +1,7 @@ module WasmF64Test -include "runtime/unsafe/wasmf64" -include "runtime/unsafe/conv" +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/unsafe/conv" include Conv @unsafe let test = () => { diff --git a/compiler/test/stdlib/wasmi32.test.gr b/compiler/test/stdlib/wasmi32.test.gr index b21ba8240e..596a270b7e 100644 --- a/compiler/test/stdlib/wasmi32.test.gr +++ b/compiler/test/stdlib/wasmi32.test.gr @@ -1,7 +1,7 @@ module WasmI32Test -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/conv" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/conv" include Conv @unsafe let test = () => { diff --git a/compiler/test/stdlib/wasmi64.test.gr b/compiler/test/stdlib/wasmi64.test.gr index cc97060955..7552367ba3 100644 --- a/compiler/test/stdlib/wasmi64.test.gr +++ b/compiler/test/stdlib/wasmi64.test.gr @@ -1,7 +1,7 @@ module WasmI64Test -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/conv" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/conv" include Conv @unsafe let test = () => { diff --git a/compiler/test/suites/chars.re b/compiler/test/suites/chars.re index 33d0bc43d0..04ebeba3c7 100644 --- a/compiler/test/suites/chars.re +++ b/compiler/test/suites/chars.re @@ -32,12 +32,12 @@ describe("chars", ({test, testSkip}) => { assertRun("char_eq2", "print('๐ŸŒพ' == '๐Ÿ’ฏ')", "false\n"); assertRun( "char_eq3", - "include \"char\" as Char; print(Char.fromCode(0x1F33E) == '๐ŸŒพ')", + "from \"char\" include Char; print(Char.fromCode(0x1F33E) == '๐ŸŒพ')", "true\n", ); assertRun( "char_eq4", - "include \"char\" as Char; print(Char.fromCode(0x1F33E) == '๐Ÿ’ฏ')", + "from \"char\" include Char; print(Char.fromCode(0x1F33E) == '๐Ÿ’ฏ')", "false\n", ); assertRun("char_toString_escape1", {|print(('\\', 1))|}, "('\\\\', 1)\n"); diff --git a/compiler/test/suites/exceptions.re b/compiler/test/suites/exceptions.re index a6eeb6e97a..b6d6c3c0c4 100644 --- a/compiler/test/suites/exceptions.re +++ b/compiler/test/suites/exceptions.re @@ -38,13 +38,13 @@ describe("exceptions", ({test, testSkip}) => { ); assertRunError( "exception_register_1", - {|include "exception"; exception HorribleError; Exception.registerPrinter(e => match (e) { HorribleError => Some("Spooky error"), _ => None }); let _ = throw HorribleError|}, + {|from "exception" include Exception; exception HorribleError; Exception.registerPrinter(e => match (e) { HorribleError => Some("Spooky error"), _ => None }); let _ = throw HorribleError|}, "Spooky error", ); assertRunError( "exception_register_2", {| - include "exception" + from "exception" include Exception exception HorribleError Exception.registerPrinter(e => match (e) { HorribleError => Some("Spooky error 1"), _ => None }) Exception.registerPrinter(e => match (e) { HorribleError => Some("Spooky error 2"), _ => None }) @@ -59,7 +59,7 @@ describe("exceptions", ({test, testSkip}) => { ); assertRunError( "record_exception_2", - {|include "exception"; exception Foo { msg: String, bar: Number }; Exception.registerPrinter(e => match (e) { Foo { msg, bar } => Some(msg ++ toString(bar)), _ => None }); let _ = throw Foo{msg: "Oops", bar: 1}|}, + {|from "exception" include Exception; exception Foo { msg: String, bar: Number }; Exception.registerPrinter(e => match (e) { Foo { msg, bar } => Some(msg ++ toString(bar)), _ => None }); let _ = throw Foo{msg: "Oops", bar: 1}|}, "Oops1", ); }); diff --git a/compiler/test/suites/gc.re b/compiler/test/suites/gc.re index 73bd38e2f7..a1fcfb3e11 100644 --- a/compiler/test/suites/gc.re +++ b/compiler/test/suites/gc.re @@ -4,9 +4,9 @@ open Grain_tests.Runner; let makeGcProgram = (program, heap_size) => { Printf.sprintf( {| - include "runtime/unsafe/wasmi32" - include "runtime/malloc" - include "runtime/unsafe/memory" + from "runtime/unsafe/wasmi32" include WasmI32 + from "runtime/malloc" include Malloc + from "runtime/unsafe/memory" include Memory @disableGC primitive heapStart = "@heap.start" @@ -136,7 +136,7 @@ describe("garbage collection", ({test, testSkip}) => { "long_lists", 20000, {| - include "list" + from "list" include List use List.* let rec make_list = (x, n) => { diff --git a/compiler/test/suites/includes.re b/compiler/test/suites/includes.re index 912930a23e..9499dec32d 100644 --- a/compiler/test/suites/includes.re +++ b/compiler/test/suites/includes.re @@ -15,127 +15,135 @@ describe("includes", ({test, testSkip}) => { /* use * tests */ assertRun( "include_all", - "include \"provideAll\" as ProvideAll; use ProvideAll.*; {print(x); print(y(4)); print(z)}", + "from \"provideAll\" include ProvideAll; use ProvideAll.*; {print(x); print(y(4)); print(z)}", "5\n4\nfoo\n", ); assertSnapshot( "include_all_constructor", - "include \"tlists\" as TLists; use TLists.*; Cons(2, Empty)", + "from \"tlists\" include TLists; use TLists.*; Cons(2, Empty)", ); /* use {} tests */ assertSnapshot( "include_some", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x}; x", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x}; x", ); assertSnapshot( "include_some_multiple", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x, y}; y(x)", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x, y}; y(x)", ); assertSnapshot( "include_some_multiple_trailing", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x, y,}; y(x)", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x, y,}; y(x)", ); assertSnapshot( "include_some_multiple_trailing2", - "include \"provideAll\" as ProvideAll; use ProvideAll.{ + "from \"provideAll\" include ProvideAll; use ProvideAll.{ x, y, }; y(x)", ); assertSnapshot( "include_some_constructor", - "include \"tlists\" as TLists; use TLists.{type TList}; Cons(5, Empty)", + "from \"tlists\" include TLists; use TLists.{type TList}; Cons(5, Empty)", ); assertSnapshot( "include_some_mixed", - "include \"tlists\" as TLists; use TLists.{type TList, sum}; sum(Cons(5, Empty))", + "from \"tlists\" include TLists; use TLists.{type TList, sum}; sum(Cons(5, Empty))", ); assertSnapshot( "include_alias", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x as y}; y", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x as y}; y", ); assertSnapshot( "include_alias_multiple", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x as y, y as x}; x(y)", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x as y, y as x}; x(y)", ); /* use {} errors */ assertCompileError( "include_some_error", - "include \"provideAll\" as ProvideAll; use ProvideAll.{a}; a", + "from \"provideAll\" include ProvideAll; use ProvideAll.{a}; a", "Unbound value a in module ProvideAll", ); assertCompileError( "include_some_error2", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x, a}; a", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x, a}; a", "Unbound value a in module ProvideAll", ); assertCompileError( "include_some_error3", - "include \"provideAll\" as ProvideAll; use ProvideAll.{module Foo}", + "from \"provideAll\" include ProvideAll; use ProvideAll.{module Foo}", "Unbound module Foo in module ProvideAll", ); assertCompileError( "include_some_error4", - "include \"provideAll\" as ProvideAll; use ProvideAll.{x, module Foo}", + "from \"provideAll\" include ProvideAll; use ProvideAll.{x, module Foo}", "Unbound module Foo in module ProvideAll", ); assertCompileError( "include_some_error5", - "include \"provideAll\" as ProvideAll; use ProvideAll.{Foo}", + "from \"provideAll\" include ProvideAll; use ProvideAll.{Foo}", "Expected a lowercase identifier to use a value, the keyword `module` followed by an uppercase identifier to use a module, or the keyword `type` followed by an uppercase identifier to use a type.", ); assertCompileError( "include_some_error6", - "include \"provideAll\" as ProvideAll; use ProvideAll.{a, Foo}", + "from \"provideAll\" include ProvideAll; use ProvideAll.{a, Foo}", "Expected a lowercase identifier to use a value, the keyword `module` followed by an uppercase identifier to use a module, the keyword `type` followed by an uppercase identifier to use a type, or `}` to end the use statement.", ); /* include module tests */ - assertSnapshot("include_module", "include \"provideAll\" as Foo; Foo.x"); + assertSnapshot( + "include_module", + "from \"provideAll\" include ProvideAll as Foo; Foo.x", + ); assertSnapshot( "include_module2", - "include \"provideAll\" as Foo; Foo.y(Foo.x)", + "from \"provideAll\" include ProvideAll as Foo; Foo.y(Foo.x)", ); /* include module errors */ assertCompileError( "include_module_error", - "include \"provideAll\" as Foo; Foo.foo", + "from \"provideAll\" include ProvideAll as Foo; Foo.foo", "Unbound value foo in module Foo", ); + assertCompileError( + "include_module_error", + "from \"provideAll\" include Foo; Foo.foo", + "This statement includes module Foo, but the file at the path defines module ProvideAll. Did you mean `include ProvideAll as Foo`?", + ); /* use well-formedness errors */ assertCompileError( "include_alias_illegal_renaming", - "include \"list\" as List; use List.{module Cons as cons, module Empty}; cons(3, Empty)", + "from \"list\" include List; use List.{module Cons as cons, module Empty}; cons(3, Empty)", "Expected an uppercase module alias", ); assertCompileError( "include_alias_illegal_renaming2", - "include \"list\" as List; use List.{sum as Sum, module Empty}; sum(Empty)", + "from \"list\" include List; use List.{sum as Sum, module Empty}; sum(Empty)", "Expected a lowercase alias", ); assertCompileError( "include_module_illegal_name", - "include \"list\" as foo;", + "from \"list\" include List as foo;", "Expected an uppercase module identifier", ); assertCompileError( "include_module_not_external", - "include \"list\" as Foo.Foo;", + "from \"list\" include List as Foo.Foo;", "A module alias cannot contain `.` as that would reference a binding within another module.", ); assertCompileError( "include_value_not_external", - "include \"list\" as List; use List.{foo as Foo.foo};", + "from \"list\" include List; use List.{foo as Foo.foo};", "Expected a lowercase alias", ); /* include multiple modules tests */ assertSnapshot( "include_muliple_modules", - "include \"tlists\" as TLists; use TLists.*; include \"provideAll\" as ProvideAll; use ProvideAll.*; Cons(x, Empty)", + "from \"tlists\" include TLists; use TLists.*; from \"provideAll\" include ProvideAll; use ProvideAll.*; Cons(x, Empty)", ); /* include same module tests */ assertSnapshot( "include_same_module_unify", - "include \"tlists\" as TLists; use TLists.*; Cons(5, TLists.Empty)", + "from \"tlists\" include TLists; use TLists.*; Cons(5, TLists.Empty)", ); /* include filepath tests */ assertFileSnapshot("include_relative_path1", "relativeInclude1"); @@ -144,7 +152,7 @@ describe("includes", ({test, testSkip}) => { assertFileSnapshot("include_relative_path4", "relativeIncludes/foo"); assertCompileError( "include_missing_file", - "include \"foo\" as Foo; 2", + "from \"foo\" include Foo; 2", "Missing file for module foo", ); /* Unbound module tests */ @@ -156,13 +164,13 @@ describe("includes", ({test, testSkip}) => { /* Misc include tests */ assertCompileError( "test_bad_import", - "{let x = (1, 2); include \"tlists\" as TLists; x}", + "{let x = (1, 2); from \"tlists\" include TLists; x}", "error", ); assertFileRun("test_file_same_name", "list", "OK\n"); assertSnapshot( "annotation_across_import", - "include \"tlists\" as TLists; use TLists.{ type TList }; let foo : TLists.TList = Empty; foo", + "from \"tlists\" include TLists; use TLists.{ type TList }; let foo : TLists.TList = Empty; foo", ); assertFileRun( "relative_include_linking", @@ -172,21 +180,21 @@ describe("includes", ({test, testSkip}) => { assertFileCompileError( "include_broken", "brokenIncludes/main", - "./broken.gr\", line 4, characters 8-15", + "./broken.gr\", line 4, characters 5-12", ); assertRun( "reprovide_values", - "include \"reprovideContents\"; use ReprovideContents.{ type Type, module Mod }; print(A); print(Mod.val)", + "from \"reprovideContents\" include ReprovideContents; use ReprovideContents.{ type Type, module Mod }; print(A); print(Mod.val)", "A\n123\n", ); assertRun( "reprovide_type2", - "include \"reprovideContents\"; use ReprovideContents.{ type OtherT as TT, val }; print(val); print({ x: 2 })", + "from \"reprovideContents\" include ReprovideContents; use ReprovideContents.{ type OtherT as TT, val }; print(val); print({ x: 2 })", "{\n x: 1\n}\n{\n x: 2\n}\n", ); assertRun( "reprovide_type3", - "include \"reprovideContents\"; use ReprovideContents.{ type OtherT as Other }; print({ x: 1 }: Other)", + "from \"reprovideContents\" include ReprovideContents; use ReprovideContents.{ type OtherT as Other }; print({ x: 1 }: Other)", "{\n x: 1\n}\n", ); }); diff --git a/compiler/test/suites/let_mut.re b/compiler/test/suites/let_mut.re index f20076cd23..ce92b0b95b 100644 --- a/compiler/test/suites/let_mut.re +++ b/compiler/test/suites/let_mut.re @@ -99,7 +99,7 @@ describe("let mut", ({test, testSkip}) => { /* Exported let mut */ assertRun( "let-mut_export1", - "include \"letMutProvide\" as LetMutProvide; use LetMutProvide.{ x }; print(x); x = 5; x = 6; print(x)", + "from \"letMutProvide\" include LetMutProvide; use LetMutProvide.{ x }; print(x); x = 5; x = 6; print(x)", "3\n6\n", ); /* unsafe let mut in a loop */ diff --git a/compiler/test/suites/linking.re b/compiler/test/suites/linking.re index 175ff747ba..9ff4975ce6 100644 --- a/compiler/test/suites/linking.re +++ b/compiler/test/suites/linking.re @@ -20,7 +20,7 @@ describe("linking", ({test, testSkip}) => { ); assertRun( "link_import", - {|include "list"; print(List.map(n => n + 1, [1, 2, 3]))|}, + {|from "list" include List; print(List.map(n => n + 1, [1, 2, 3]))|}, "[2, 3, 4]\n", ); assertRun("link_issue_994_no_generated_code", {|0|}, ""); diff --git a/compiler/test/suites/modules.re b/compiler/test/suites/modules.re index 5e78b3c401..475a4d1d71 100644 --- a/compiler/test/suites/modules.re +++ b/compiler/test/suites/modules.re @@ -103,7 +103,7 @@ describe("modules", ({test, testSkip}) => { "local_module_include", {| module Foo { - include "list" + from "list" include List } |}, "`include` statements may only appear at the file level", @@ -136,7 +136,7 @@ describe("modules", ({test, testSkip}) => { {| module ReprovidedSimple - include "simpleModule" + from "simpleModule" include Simple provide { module Simple } |}, ); diff --git a/compiler/test/suites/numbers.re b/compiler/test/suites/numbers.re index 1364d46ddb..deea93f564 100644 --- a/compiler/test/suites/numbers.re +++ b/compiler/test/suites/numbers.re @@ -96,7 +96,7 @@ describe("numbers", ({test, testSkip}) => { assertRun("nan_equality1", {|print(NaNf == NaNf)|}, "false\n"); assertRun( "nan_equality2", - {|include "float64"; use Float64.{ (/) }; print((0.0d / 0.0d) == (0.0d / 0.0d))|}, + {|from "float64" include Float64; use Float64.{ (/) }; print((0.0d / 0.0d) == (0.0d / 0.0d))|}, "false\n", ); assertRun("nan_equality3", {|print(0.0 / 0.0 == 0.0 / 0.0)|}, "false\n"); @@ -159,32 +159,32 @@ describe("numbers", ({test, testSkip}) => { // runtime errors assertRunError( "unsigned_overflow_err1", - {|include "uint32"; let n = -1; print(Uint32.fromNumber(n))|}, + {|from "uint32" include Uint32; let n = -1; print(Uint32.fromNumber(n))|}, "Overflow: Number overflow", ); assertRunError( "unsigned_overflow_err2", - {|include "uint32"; let n = 0x1ffffffff; print(Uint32.fromNumber(n))|}, + {|from "uint32" include Uint32; let n = 0x1ffffffff; print(Uint32.fromNumber(n))|}, "Overflow: Number overflow", ); assertRunError( "unsigned_overflow_err3", - {|include "uint64"; let n = -1; print(Uint64.fromNumber(n))|}, + {|from "uint64" include Uint64; let n = -1; print(Uint64.fromNumber(n))|}, "Overflow: Number overflow", ); assertRunError( "unsigned_overflow_err4", - {|include "uint64"; let n = 0x1ffffffffffffffff; print(Uint64.fromNumber(n))|}, + {|from "uint64" include Uint64; let n = 0x1ffffffffffffffff; print(Uint64.fromNumber(n))|}, "Overflow: Number overflow", ); assertRunError( "shortnum_err1", - {|include "uint8"; print(Uint8.fromNumber(-1))|}, + {|from "uint8" include Uint8; print(Uint8.fromNumber(-1))|}, "Overflow: Number overflow", ); assertRunError( "shortnum_err2", - {|include "uint8"; print(Uint8.fromNumber(256))|}, + {|from "uint8" include Uint8; print(Uint8.fromNumber(256))|}, "Overflow: Number overflow", ); assertCompileError( diff --git a/compiler/test/suites/optimizations.re b/compiler/test/suites/optimizations.re index ba75bee7f6..b949b575b1 100644 --- a/compiler/test/suites/optimizations.re +++ b/compiler/test/suites/optimizations.re @@ -416,8 +416,8 @@ describe("optimizations", ({test, testSkip}) => { "test_manual_gc_calls_removed", {| /* grainc-flags --no-gc */ - include "runtime/unsafe/memory" - include "runtime/unsafe/wasmi32" + from "runtime/unsafe/memory" include Memory + from "runtime/unsafe/wasmi32" include WasmI32 @disableGC provide let foo = (x, y, z) => { Memory.incRef(WasmI32.fromGrain((+))) @@ -486,7 +486,7 @@ describe("optimizations", ({test, testSkip}) => { "test_no_bulk_memory_calls", ~config_fn=() => {Grain_utils.Config.bulk_memory := false}, {| - include "runtime/unsafe/memory" + from "runtime/unsafe/memory" include Memory @disableGC provide let foo = () => { Memory.fill(0n, 0n, 0n) @@ -572,7 +572,7 @@ describe("optimizations", ({test, testSkip}) => { "test_memory_fill_calls_replaced", ~config_fn=() => {Grain_utils.Config.bulk_memory := true}, {| - include "runtime/unsafe/memory" + from "runtime/unsafe/memory" include Memory @disableGC provide let foo = () => { Memory.fill(0n, 0n, 0n) diff --git a/compiler/test/suites/print.re b/compiler/test/suites/print.re index 423fe0679b..12b40ded72 100644 --- a/compiler/test/suites/print.re +++ b/compiler/test/suites/print.re @@ -34,7 +34,7 @@ describe("print", ({test, testSkip}) => { ); assertRun( "print_issue892_1", - "include \"list\" as List\nlet a = [1, 2]\nlet b = List.reverse(a)\nprint(a)\nprint(b)\n", + "from \"list\" include List\nlet a = [1, 2]\nlet b = List.reverse(a)\nprint(a)\nprint(b)\n", "[1, 2]\n[2, 1]\n", ); assertRun( diff --git a/compiler/test/suites/provides.re b/compiler/test/suites/provides.re index dde34127f8..22ba3386be 100644 --- a/compiler/test/suites/provides.re +++ b/compiler/test/suites/provides.re @@ -48,48 +48,48 @@ describe("provides", ({test, testSkip}) => { assertCompileError( "provide1", - "include \"noProvides\" as NoProvides; use NoProvides.*; x", + "from \"noProvides\" include NoProvides; use NoProvides.*; x", "Unbound value x", ); assertCompileError( "provide2", - "include \"noProvides\" as NoProvides; use NoProvides.*; y", + "from \"noProvides\" include NoProvides; use NoProvides.*; y", "Unbound value y", ); assertCompileError( "provide3", - "include \"noProvides\" as NoProvides; use NoProvides.*; z", + "from \"noProvides\" include NoProvides; use NoProvides.*; z", "Unbound value z", ); assertSnapshot( "provide4", - "include \"onlyXProvided\" as OnlyXProvided; use OnlyXProvided.*; x", + "from \"onlyXProvided\" include OnlyXProvided; use OnlyXProvided.*; x", ); assertCompileError( "provide5", - "include \"onlyXProvided\" as OnlyXProvided; use OnlyXProvided.*; y", + "from \"onlyXProvided\" include OnlyXProvided; use OnlyXProvided.*; y", "Unbound value y", ); assertCompileError( "provide6", - "include \"onlyXProvided\" as OnlyXProvided; use OnlyXProvided.*; z", + "from \"onlyXProvided\" include OnlyXProvided; use OnlyXProvided.*; z", "Unbound value z", ); assertSnapshot( "provide7", - "include \"provideAll\" as ProvideAll; use ProvideAll.*; x", + "from \"provideAll\" include ProvideAll; use ProvideAll.*; x", ); assertSnapshot( "provide8", - "include \"provideAll\" as ProvideAll; use ProvideAll.*; x + y(4)", + "from \"provideAll\" include ProvideAll; use ProvideAll.*; x + y(4)", ); assertSnapshot( "provide9", - "include \"provideAll\" as ProvideAll; use ProvideAll.*; y(z)", + "from \"provideAll\" include ProvideAll; use ProvideAll.*; y(z)", ); assertCompileError( "provide10", - "include \"provideAll\" as ProvideAll; use ProvideAll.*; y(secret)", + "from \"provideAll\" include ProvideAll; use ProvideAll.*; y(secret)", "Unbound value secret", ); assertCompileError( @@ -100,7 +100,7 @@ describe("provides", ({test, testSkip}) => { assertSnapshot( "provide12", {| - include "providedType" + from "providedType" include ProvidedType ProvidedType.apply((arg) => print("ok")) |}, ); @@ -165,23 +165,23 @@ describe("provides", ({test, testSkip}) => { ); assertRunError( "provide_exceptions1", - "include \"provideException\"; let f = () => if (true) { throw ProvideException.MyException }; f()", + "from \"provideException\" include ProvideException; let f = () => if (true) { throw ProvideException.MyException }; f()", "OriginalException", ); assertRunError( "provide_exceptions2", - "include \"reprovideException\"; use ReprovideException.*; let f = () => if (true) { throw MyException }; f()", + "from \"reprovideException\" include ReprovideException; use ReprovideException.*; let f = () => if (true) { throw MyException }; f()", "OriginalException", ); assertRunError( "provide_exceptions3", - "include \"reprovideException\"; use ReprovideException.{ exception MyException as E }; let f = () => if (true) { throw E }; f()", + "from \"reprovideException\" include ReprovideException; use ReprovideException.{ exception MyException as E }; let f = () => if (true) { throw E }; f()", "OriginalException", ); assertRun( "provide_exceptions4", {| - include "reprovideException" + from "reprovideException" include ReprovideException use ReprovideException.{ exception MyException, excVal1, excVal2 } match (excVal1) { MyException => print("good1"), diff --git a/compiler/test/suites/records.re b/compiler/test/suites/records.re index d26f7f4d2b..c5e85b83d4 100644 --- a/compiler/test/suites/records.re +++ b/compiler/test/suites/records.re @@ -182,7 +182,7 @@ describe("records", ({test, testSkip}) => { assertRun( "export_import_record_issue_665", {| - include "data" + from "data" include Data use Data.{ type Foo } provide enum Bar { Baz(Foo) } print(Baz({ bar: 1 })) diff --git a/compiler/test/suites/stdlib.re b/compiler/test/suites/stdlib.re index 338181852b..2d9438b733 100644 --- a/compiler/test/suites/stdlib.re +++ b/compiler/test/suites/stdlib.re @@ -15,7 +15,7 @@ describe("stdlib", ({test, testSkip}) => { assertSnapshot("stdlib_equal_1", "(1, 2) is (1, 2)"); assertSnapshot( "stdlib_equal_2", - "include \"pervasives\" as Pervasives; use Pervasives.*; (1, 2) == (1, 2)", + "from \"pervasives\" include Pervasives; use Pervasives.*; (1, 2) == (1, 2)", ); assertSnapshot("stdlib_equal_3", "[1, 2, 3] == [1, 2, 3]"); assertSnapshot("stdlib_equal_4", "1 == 1"); @@ -53,20 +53,20 @@ describe("stdlib", ({test, testSkip}) => { assertFileRun("recursive_equal_mut", "recursive-equal-mut", "OK\n"); assertCompileError( "stdlib_length_err", - "include \"list\" as List; use List.*; length(true)", + "from \"list\" include List; use List.*; length(true)", "This expression has type Bool but", ); assertCompileError( "stdlib_reverse_err", - "include \"list\" as List; use List.*; reverse(1)", + "from \"list\" include List; use List.*; reverse(1)", "This expression has type Number but", ); // logging to the stdout file descriptor assertRun( "stdlib_file_stdout", {| - include "bytes" - include "sys/file" + from "bytes" include Bytes + from "sys/file" include File ignore(File.fdWrite(File.stdout, Bytes.fromString("enterthe"))) print(void) |}, diff --git a/compiler/test/suites/strings.re b/compiler/test/suites/strings.re index 6d723c6b2b..6d1dfaabe3 100644 --- a/compiler/test/suites/strings.re +++ b/compiler/test/suites/strings.re @@ -331,17 +331,17 @@ bar", 1))|}, assertRun("string_float3", {|print(-Infinityf)|}, "-Infinity\n"); assertRun( "string_float4", - {|include "float64"; use Float64.*; print(0.0d / 0.0d)|}, + {|from "float64" include Float64; use Float64.*; print(0.0d / 0.0d)|}, "NaN\n", ); assertRun( "string_float5", - {|include "float64"; use Float64.*; print(1.0d / 0.0d)|}, + {|from "float64" include Float64; use Float64.*; print(1.0d / 0.0d)|}, "Infinity\n", ); assertRun( "string_float6", - {|include "float64"; use Float64.*; print(-1.0d / 0.0d)|}, + {|from "float64" include Float64; use Float64.*; print(-1.0d / 0.0d)|}, "-Infinity\n", ); diff --git a/compiler/test/suites/types.re b/compiler/test/suites/types.re index 8cc9340856..c3aa4acc44 100644 --- a/compiler/test/suites/types.re +++ b/compiler/test/suites/types.re @@ -120,7 +120,7 @@ describe("aliased types", ({test, testSkip}) => { assertRun( "import_type_alias_1", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let foo1 = 123 : Foo let foo2: Foo = 234 @@ -132,7 +132,7 @@ describe("aliased types", ({test, testSkip}) => { assertRun( "import_type_alias_2", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let foo1 = [234] : (Bar) let foo2: Bar = [123, ...foo1] @@ -143,7 +143,7 @@ describe("aliased types", ({test, testSkip}) => { assertRun( "import_type_alias_3", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let foo: Baz = baz print(foo: Baz) @@ -153,7 +153,7 @@ describe("aliased types", ({test, testSkip}) => { assertRun( "import_type_alias_4", {| - include "aliases" + from "aliases" include Aliases use Aliases.{ type Foo } let foo: Foo = 5 print(foo) @@ -163,7 +163,7 @@ describe("aliased types", ({test, testSkip}) => { assertRun( "import_type_alias_5", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let foo: Qux = qux print(foo: Qux) @@ -173,7 +173,7 @@ describe("aliased types", ({test, testSkip}) => { assertCompileError( "err_import_type_alias_1", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let bar = 5: Baz |}, @@ -183,7 +183,7 @@ describe("aliased types", ({test, testSkip}) => { assertCompileError( "err_import_type_alias_2", {| - include "aliases" + from "aliases" include Aliases use Aliases.* let bar: Qux = 5 |}, @@ -193,7 +193,7 @@ describe("aliased types", ({test, testSkip}) => { assertCompileError( "err_import_type_alias_3", {| - include "aliases" + from "aliases" include Aliases use Aliases.{ type Foo, baz } let foo: Foo = baz |}, @@ -360,7 +360,7 @@ describe("abstract types", ({test, testSkip}) => { assertRun( "regression_annotated_func_export", {| - include "funcAliasProvide" as A + from "funcAliasProvide" include FuncAliasProvide as A print(A.function()) |}, "abc\n", @@ -471,7 +471,7 @@ describe("function types", ({test, testSkip}) => { assertRun( "type_fn_4", {| - include "map" + from "map" include Map type Foo = Map.Map, Map.Map> => Map.Map let f: Foo = a => Map.make() print(f(Map.make()) == Map.make()) @@ -481,7 +481,7 @@ describe("function types", ({test, testSkip}) => { assertRun( "type_fn_5", {| - include "map" + from "map" include Map type Foo = Map.Map => Map.Map => Number let f: Foo = a => b => 1 print(f(Map.make())(Map.make())) diff --git a/compiler/test/suites/wasi_args.re b/compiler/test/suites/wasi_args.re index 7dc929c089..6735ad7a84 100644 --- a/compiler/test/suites/wasi_args.re +++ b/compiler/test/suites/wasi_args.re @@ -8,9 +8,9 @@ describe("wasi args and env", ({test, testSkip}) => { let assertRun = makeRunner(test_or_skip); let print_wasi_info = {| - include "sys/process" - include "array" - include "string" + from "sys/process" include Process + from "array" include Array + from "string" include String match (Process.argv()) { Ok(args) => print(Array.slice(1, args)), diff --git a/compiler/test/test-libs/providedType.gr b/compiler/test/test-libs/providedType.gr index ce17d9f878..d3ab83c2da 100644 --- a/compiler/test/test-libs/providedType.gr +++ b/compiler/test/test-libs/providedType.gr @@ -1,6 +1,6 @@ module ProvidedType -include "map" +from "map" include Map provide let apply = (f: Map.Map => Void) => { let map = Map.make() diff --git a/compiler/test/test-libs/reprovideContents.gr b/compiler/test/test-libs/reprovideContents.gr index 19a0017efb..57f86d3509 100644 --- a/compiler/test/test-libs/reprovideContents.gr +++ b/compiler/test/test-libs/reprovideContents.gr @@ -1,6 +1,6 @@ module ReprovideContents -include "./provideContents" +from "./provideContents" include ProvideContents use ProvideContents.{ type Type, type Other as OtherT, module Mod } diff --git a/compiler/test/test-libs/reprovideException.gr b/compiler/test/test-libs/reprovideException.gr index bac89fb923..0b9f545f30 100644 --- a/compiler/test/test-libs/reprovideException.gr +++ b/compiler/test/test-libs/reprovideException.gr @@ -1,6 +1,6 @@ module ReprovideException -include "./provideException" +from "./provideException" include ProvideException use ProvideException.{ exception MyException, excVal1 } let excVal2 = ProvideException.MyException diff --git a/stdlib/README.md b/stdlib/README.md index 7132a24aae..5b44264664 100644 --- a/stdlib/README.md +++ b/stdlib/README.md @@ -22,7 +22,7 @@ For example, you can import the `number` stdlib: ```grain module Main -include "number" +from "number" include Number assert Number.abs(-1) == 1 ``` @@ -51,6 +51,7 @@ grain format ./stdlib/ -o ./stdlib/ ``` To run the `stdlib` tests you can run: + ```sh npm run compiler test -- --filter stdlib ``` diff --git a/stdlib/array.gr b/stdlib/array.gr index 8a62cff415..557a5767c2 100644 --- a/stdlib/array.gr +++ b/stdlib/array.gr @@ -3,7 +3,7 @@ * * An immutable array implementation is available in the `Immutable` submodule. * - * @example include "array" + * @example from "array" include Array * @example [> 1, 2, 3] * * @since v0.2.0 @@ -12,14 +12,14 @@ */ module Array -include "number" -include "list" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/memory" -include "runtime/dataStructures" +from "number" include Number +from "list" include List +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateArray, tagSimpleNumber } -include "runtime/exception" -include "runtime/numbers" +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToWasmI32 } @unsafe diff --git a/stdlib/array.md b/stdlib/array.md index 7f9dcc8264..cdb07a9310 100644 --- a/stdlib/array.md +++ b/stdlib/array.md @@ -20,7 +20,7 @@ An immutable array implementation is available in the `Immutable` submodule. ```grain -include "array" +from "array" include Array ``` ```grain diff --git a/stdlib/bigint.gr b/stdlib/bigint.gr index c6ee57cd90..2b3ba8db34 100644 --- a/stdlib/bigint.gr +++ b/stdlib/bigint.gr @@ -1,7 +1,7 @@ /** * Utilities for working with the BigInt type. * - * @example include "bigint" + * @example from "bigint" include Bigint * * @example 9223372036854775809t * @example 0t @@ -11,12 +11,12 @@ */ module BigInt -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/memory" -include "runtime/bigint" as BI -include "runtime/dataStructures" as DS +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/bigint" include Bigint as BI +from "runtime/dataStructures" include DataStructures as DS -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToBigInt as fromNumber, coerceBigIntToNumber as toNumber, diff --git a/stdlib/bigint.md b/stdlib/bigint.md index 9f17c1cfa4..19fab523d0 100644 --- a/stdlib/bigint.md +++ b/stdlib/bigint.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "bigint" +from "bigint" include Bigint ``` ```grain diff --git a/stdlib/buffer.gr b/stdlib/buffer.gr index fa439750b3..9a0bb36aad 100644 --- a/stdlib/buffer.gr +++ b/stdlib/buffer.gr @@ -3,7 +3,7 @@ * * Buffers are data structures that automatically expand as more data is appended. They are useful for storing and operating on an unknown number of bytes. All set or append operations mutate the buffer. * - * @example include "buffer" + * @example from "buffer" include Buffer * * @example Buffer.make(64) * @@ -11,17 +11,17 @@ */ module Buffer -include "runtime/unsafe/memory" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/conv" -include "runtime/exception" -include "runtime/dataStructures" +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/conv" include Conv +from "runtime/exception" include Exception +from "runtime/dataStructures" include DataStructures use DataStructures.{ untagChar } -include "int32" -include "bytes" -include "string" -include "char" -include "runtime/numbers" +from "int32" include Int32 +from "bytes" include Bytes +from "string" include String +from "char" include Char +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToWasmI32 } abstract record Buffer { diff --git a/stdlib/buffer.md b/stdlib/buffer.md index 98364bf0d2..9b89608020 100644 --- a/stdlib/buffer.md +++ b/stdlib/buffer.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "buffer" +from "buffer" include Buffer ``` ```grain diff --git a/stdlib/bytes.gr b/stdlib/bytes.gr index 469cc47cf3..7c52c5e766 100644 --- a/stdlib/bytes.gr +++ b/stdlib/bytes.gr @@ -1,7 +1,7 @@ /** * Utilities for working with byte sequences. * - * @example include "bytes" + * @example from "bytes" include Bytes * * @example b"\x00" * @example Bytes.make(1) @@ -10,13 +10,13 @@ */ module Bytes -include "runtime/unsafe/memory" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" -include "runtime/unsafe/conv" -include "runtime/dataStructures" +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/unsafe/conv" include Conv +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagInt8, tagUint8, @@ -29,9 +29,9 @@ use DataStructures.{ allocateBytes, allocateString, } -include "runtime/exception" -include "int32" -include "runtime/numbers" +from "runtime/exception" include Exception +from "int32" include Int32 +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToWasmI32 } @unsafe diff --git a/stdlib/bytes.md b/stdlib/bytes.md index ba341817c6..e5163776a6 100644 --- a/stdlib/bytes.md +++ b/stdlib/bytes.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "bytes" +from "bytes" include Bytes ``` ```grain diff --git a/stdlib/char.gr b/stdlib/char.gr index a1fee7d144..5b699c138c 100644 --- a/stdlib/char.gr +++ b/stdlib/char.gr @@ -3,7 +3,7 @@ * * The Char type represents a single [Unicode scalar value](https://www.unicode.org/glossary/#unicode_scalar_value). * - * @example include "char" + * @example from "char" include Char * * @example 'a' * @example '1' @@ -13,8 +13,8 @@ */ module Char -include "runtime/unsafe/wasmi32" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber, tagChar, untagChar, allocateString } exception MalformedUtf8 diff --git a/stdlib/char.md b/stdlib/char.md index 855e0b0adc..30b6d412db 100644 --- a/stdlib/char.md +++ b/stdlib/char.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "char" +from "char" include Char ``` ```grain diff --git a/stdlib/exception.gr b/stdlib/exception.gr index b551e7f495..d4c784f02c 100644 --- a/stdlib/exception.gr +++ b/stdlib/exception.gr @@ -3,7 +3,7 @@ * * The Exception type represents an error that has occurred during computation. * - * @example include "exception" + * @example from "exception" include Exception * * @example exception ExampleError(Number) * @example exception ExampleError @@ -12,9 +12,9 @@ */ module Exception -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/memory" -include "runtime/exception" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/exception" include Exception /** * Registers an exception printer. When an exception is thrown, all registered diff --git a/stdlib/exception.md b/stdlib/exception.md index 36509881eb..fed3e78b7e 100644 --- a/stdlib/exception.md +++ b/stdlib/exception.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "exception" +from "exception" include Exception ``` ```grain diff --git a/stdlib/float32.gr b/stdlib/float32.gr index da60bfa74d..6e06133606 100644 --- a/stdlib/float32.gr +++ b/stdlib/float32.gr @@ -1,7 +1,7 @@ /** * Utilities for working with the Float32 type. * - * @example include "float32" + * @example from "float32" include Float32 * * @example 4.0f * @example -4.0f @@ -12,13 +12,13 @@ */ module Float32 -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmf32" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmf32" include WasmF32 use WasmF32.{ (+), (-), (*), (/), (<), (<=), (>), (>=) } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newFloat32 } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToFloat32 as fromNumber, coerceFloat32ToNumber as toNumber, diff --git a/stdlib/float32.md b/stdlib/float32.md index 2b525c481f..2bfb0b1ba1 100644 --- a/stdlib/float32.md +++ b/stdlib/float32.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "float32" +from "float32" include Float32 ``` ```grain diff --git a/stdlib/float64.gr b/stdlib/float64.gr index c0b256a14b..b93e263bb3 100644 --- a/stdlib/float64.gr +++ b/stdlib/float64.gr @@ -1,7 +1,7 @@ /** * Utilities for working with the Float64 type. * - * @example include "float64" + * @example from "float64" include Float64 * * @example 5.0d * @example -5.0d @@ -12,13 +12,13 @@ */ module Float64 -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmf64" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmf64" include WasmF64 use WasmF64.{ (-), (+), (*), (/), (<), (<=), (>), (>=) } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newFloat64 } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToFloat64 as fromNumber, coerceFloat64ToNumber as toNumber, diff --git a/stdlib/float64.md b/stdlib/float64.md index ce0510768e..857012076a 100644 --- a/stdlib/float64.md +++ b/stdlib/float64.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "float64" +from "float64" include Float64 ``` ```grain diff --git a/stdlib/hash.gr b/stdlib/hash.gr index be72a720ee..f4dfcbdf88 100644 --- a/stdlib/hash.gr +++ b/stdlib/hash.gr @@ -1,7 +1,7 @@ /** * Utilities for hashing any value. * - * @example include "hash" + * @example from "hash" include Hash * * @since v0.1.0 */ @@ -11,7 +11,7 @@ module Hash This module implements MurmurHash3 for Grain data types. https://en.wikipedia.org/wiki/MurmurHash */ -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -27,17 +27,17 @@ use WasmI32.{ gtU as (>), ltU as (<), } -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/tags" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/tags" include Tags -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToWasmI32 } -include "runtime/bigint" as BI +from "runtime/bigint" include Bigint as BI -include "sys/random" -include "result" +from "sys/random" include Random +from "result" include Result @unsafe let seed = { diff --git a/stdlib/hash.md b/stdlib/hash.md index de215fe9ca..f2ea75b0a4 100644 --- a/stdlib/hash.md +++ b/stdlib/hash.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "hash" +from "hash" include Hash ``` ## Values diff --git a/stdlib/int16.gr b/stdlib/int16.gr index 37025d812b..03c16d4d73 100644 --- a/stdlib/int16.gr +++ b/stdlib/int16.gr @@ -1,12 +1,12 @@ /** * Utilities for working with the Int16 type. - * @example include "int16" + * @example from "int16" include Int16 * * @since v0.6.0 */ module Int16 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -24,13 +24,13 @@ use WasmI32.{ (>), (>=), } -include "runtime/exception" -include "runtime/numbers" +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToInt16 as fromNumber, coerceInt16ToNumber as toNumber, } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagInt16, untagInt16 } @unsafe diff --git a/stdlib/int16.md b/stdlib/int16.md index 9baa5114b5..a5a88c756a 100644 --- a/stdlib/int16.md +++ b/stdlib/int16.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "int16" +from "int16" include Int16 ``` ## Values diff --git a/stdlib/int32.gr b/stdlib/int32.gr index 150f31ae11..b88a8fe5cb 100644 --- a/stdlib/int32.gr +++ b/stdlib/int32.gr @@ -1,13 +1,13 @@ /** * Utilities for working with the Int32 type. * - * @example include "int32" + * @example from "int32" include Int32 * * @since v0.2.0 */ module Int32 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -25,13 +25,13 @@ use WasmI32.{ (>), (>=), } -include "runtime/unsafe/wasmi64" -include "runtime/exception" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/exception" include Exception -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32 } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToInt32 as fromNumber, coerceInt32ToNumber as toNumber, diff --git a/stdlib/int32.md b/stdlib/int32.md index b61a0e916d..d5f1b5d554 100644 --- a/stdlib/int32.md +++ b/stdlib/int32.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "int32" +from "int32" include Int32 ``` ## Values diff --git a/stdlib/int64.gr b/stdlib/int64.gr index 7f98dabecd..3136d77452 100644 --- a/stdlib/int64.gr +++ b/stdlib/int64.gr @@ -1,21 +1,21 @@ /** * Utilities for working with the Int64 type. * - * @example include "int64" + * @example from "int64" include Int64 * * @since v0.2.0 */ module Int64 -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 use WasmI64.{ (==), (!=), (&), (|), (^), (<<), (>>), (<), (<=), (>), (>=) } -include "runtime/exception" +from "runtime/exception" include Exception -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt64 } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToInt64 as fromNumber, coerceInt64ToNumber as toNumber, diff --git a/stdlib/int64.md b/stdlib/int64.md index 176a04ab0c..0f74677d09 100644 --- a/stdlib/int64.md +++ b/stdlib/int64.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "int64" +from "int64" include Int64 ``` ## Values diff --git a/stdlib/int8.gr b/stdlib/int8.gr index 502bca9f9c..b702edbd0d 100644 --- a/stdlib/int8.gr +++ b/stdlib/int8.gr @@ -1,6 +1,6 @@ /** * Utilities for working with the Int8 type. - * @example include "int8" + * @example from "int8" include Int8 * * @example 1s * @example -1s @@ -9,7 +9,7 @@ */ module Int8 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -28,10 +28,10 @@ use WasmI32.{ (>), (>=), } -include "runtime/exception" -include "runtime/numbers" +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToInt8 as fromNumber, coerceInt8ToNumber as toNumber } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagInt8, untagInt8 } @unsafe diff --git a/stdlib/int8.md b/stdlib/int8.md index a98ba44581..29c79017e1 100644 --- a/stdlib/int8.md +++ b/stdlib/int8.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "int8" +from "int8" include Int8 ``` ```grain diff --git a/stdlib/list.gr b/stdlib/list.gr index ea0dee44c9..e0634c22ee 100644 --- a/stdlib/list.gr +++ b/stdlib/list.gr @@ -1,7 +1,7 @@ /** * Utilities for working with lists. * - * @example include "list" + * @example from "list" include List * * @since v0.2.0 * @history v0.1.0: Originally named `lists` diff --git a/stdlib/list.md b/stdlib/list.md index da060bc4f2..62be5b4848 100644 --- a/stdlib/list.md +++ b/stdlib/list.md @@ -18,7 +18,7 @@ Utilities for working with lists. ```grain -include "list" +from "list" include List ``` ## Values diff --git a/stdlib/map.gr b/stdlib/map.gr index 3a86401119..4523292060 100644 --- a/stdlib/map.gr +++ b/stdlib/map.gr @@ -2,21 +2,21 @@ * A Map holds key-value pairs. Any value may be used as a key or value. Operations on a Map mutate the internal state, so it never needs to be re-assigned. * * An immutable map implementation is available in the `Immutable` submodule. - * @example include "map" + * @example from "map" include Map * * @since v0.2.0 */ module Map -include "list" -include "array" -include "option" -include "runtime/dataStructures" +from "list" include List +from "array" include Array +from "option" include Option +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateArray, untagSimpleNumber } -include "hash" +from "hash" include Hash use Hash.{ hash } -include "runtime/unsafe/memory" -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 // TODO: Consider implementing this as List<(Box, Box)> record rec Bucket { diff --git a/stdlib/map.md b/stdlib/map.md index e1e6bed141..875e529f2c 100644 --- a/stdlib/map.md +++ b/stdlib/map.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "map" +from "map" include Map ``` ## Types diff --git a/stdlib/marshal.gr b/stdlib/marshal.gr index 4ee22f8176..ebf20c4552 100644 --- a/stdlib/marshal.gr +++ b/stdlib/marshal.gr @@ -1,7 +1,7 @@ /** * Utilities for serializing and deserializing Grain data. * - * @example include "marshal" + * @example from "marshal" include Marshal * * @since v0.5.3 */ @@ -21,7 +21,7 @@ module Marshal or a "pointer" to a heap-allocated value. */ -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (*), @@ -36,14 +36,14 @@ use WasmI32.{ fromGrain, toGrain, } -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/unsafe/tags" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateBytes, newInt32 } -include "map" -include "set" -include "option" +from "map" include Map +from "set" include Set +from "option" include Option @unsafe let roundTo8 = n => { diff --git a/stdlib/marshal.md b/stdlib/marshal.md index 61ded8230d..23733ff24e 100644 --- a/stdlib/marshal.md +++ b/stdlib/marshal.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "marshal" +from "marshal" include Marshal ``` ## Values diff --git a/stdlib/number.gr b/stdlib/number.gr index c9b52262a5..39d0a453f8 100644 --- a/stdlib/number.gr +++ b/stdlib/number.gr @@ -14,20 +14,20 @@ /** * Utilities for working with numbers. * - * @example include "number" + * @example from "number" include Number * * @since v0.4.0 */ module Number -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" -include "runtime/unsafe/memory" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures use DataStructures.{ newFloat64, allocateString } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToWasmF64, reducedInteger, @@ -37,10 +37,10 @@ use Numbers.{ isBoxedNumber, isNaN, } -include "runtime/atoi/parse" as Atoi -include "runtime/atof/parse" as Atof -include "runtime/unsafe/tags" -include "runtime/exception" +from "runtime/atoi/parse" include Parse as Atoi +from "runtime/atof/parse" include Parse as Atof +from "runtime/unsafe/tags" include Tags +from "runtime/exception" include Exception /** * Pi represented as a Number value. diff --git a/stdlib/number.md b/stdlib/number.md index ddc24c8971..0115b282b5 100644 --- a/stdlib/number.md +++ b/stdlib/number.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "number" +from "number" include Number ``` ## Values diff --git a/stdlib/option.gr b/stdlib/option.gr index d318180375..4d490a0ca2 100644 --- a/stdlib/option.gr +++ b/stdlib/option.gr @@ -3,7 +3,7 @@ * * The Option type is an enum that represents the possibility of something being present (with the `Some` variant), or not (with the `None` variant). Thereโ€™s no standalone `null` or `nil` type in Grain; use an Option where you would normally reach for `null` or `nil`. * - * @example include "option" + * @example from "option" include Option * * @example let hasValue = Some(1234) // Creates an Option containing 1234 * @example let noValue = None // Creates an Option containing nothing diff --git a/stdlib/option.md b/stdlib/option.md index 75bd23537a..c661e64d59 100644 --- a/stdlib/option.md +++ b/stdlib/option.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "option" +from "option" include Option ``` ```grain diff --git a/stdlib/path.gr b/stdlib/path.gr index 139ecd8a8d..fa9e506c0d 100644 --- a/stdlib/path.gr +++ b/stdlib/path.gr @@ -16,17 +16,17 @@ * - Paths referencing files must not include trailing forward slashes, but paths referencing directories may * - The path segment `.` indicates the relative "current" directory of a path, and `..` indicates the parent directory of a path * - * @example include "path" + * @example from "path" include Path * * @since v0.5.5 */ module Path -include "string" -include "list" -include "option" -include "result" -include "char" +from "string" include String +from "list" include List +from "option" include Option +from "result" include Result +from "char" include Char // this module is influenced by https://github.com/reasonml/reason-native/blob/a0ddab6ab25237961e32d8732b0a222ec2372d4a/src/fp/Fp.re // with some modifications; reason-native license: diff --git a/stdlib/path.md b/stdlib/path.md index 7ccc9eba16..6ea189ac81 100644 --- a/stdlib/path.md +++ b/stdlib/path.md @@ -25,7 +25,7 @@ No other changes yet. ```grain -include "path" +from "path" include Path ``` ## Types diff --git a/stdlib/pervasives.gr b/stdlib/pervasives.gr index 91c7e0415a..22b3b7f01d 100644 --- a/stdlib/pervasives.gr +++ b/stdlib/pervasives.gr @@ -3,22 +3,22 @@ /** * This module is automatically imported into every Grain program. You can think of it as the global environment. Although it is automatically imported, it can still be imported manually. * - * @example include "pervasives" + * @example from "pervasives" include Pervasives * * @since v0.1.0 */ module Pervasives -include "runtime/exception" -include "runtime/unsafe/memory" -include "runtime/unsafe/wasmi32" +from "runtime/exception" include Exception +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 -include "runtime/equal" +from "runtime/equal" include Equal use Equal.{ equal as (==) } -include "runtime/compare" +from "runtime/compare" include Compare use Compare.{ compare } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ incr, decr, @@ -40,7 +40,7 @@ use Numbers.{ (>>>), (>>), } -include "runtime/string" +from "runtime/string" include String use String.{ toString, print, concat as (++) } /** diff --git a/stdlib/pervasives.md b/stdlib/pervasives.md index a238ec8083..0d903bed95 100644 --- a/stdlib/pervasives.md +++ b/stdlib/pervasives.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "pervasives" +from "pervasives" include Pervasives ``` ## Values diff --git a/stdlib/priorityqueue.gr b/stdlib/priorityqueue.gr index 7e4bac9821..50e6927e4a 100644 --- a/stdlib/priorityqueue.gr +++ b/stdlib/priorityqueue.gr @@ -3,16 +3,16 @@ * * An immutable priority queue implementation is available in the `Immutable` submodule. * - * @example include "priorityqueue" + * @example from "priorityqueue" include Priorityqueue * * @since v0.5.3 */ module PriorityQueue -include "array" -include "list" -include "number" -include "option" +from "array" include Array +from "list" include List +from "number" include Number +from "option" include Option /** * Mutable data structure which maintains a priority order for its elements. diff --git a/stdlib/priorityqueue.md b/stdlib/priorityqueue.md index 8d7febb18b..b18eceaaa1 100644 --- a/stdlib/priorityqueue.md +++ b/stdlib/priorityqueue.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "priorityqueue" +from "priorityqueue" include Priorityqueue ``` ## Types diff --git a/stdlib/queue.gr b/stdlib/queue.gr index 73ccd2a9f7..0b605f054f 100644 --- a/stdlib/queue.gr +++ b/stdlib/queue.gr @@ -5,14 +5,14 @@ * The default implementation is mutable, but an immutable queue * implementation is available in the `Immutable` submodule. * - * @example include "queue" + * @example from "queue" include Queue * * @since v0.2.0 */ module Queue -include "list" -include "array" +from "list" include List +from "array" include Array /** * A mutable FIFO (first-in-first-out) data structure. diff --git a/stdlib/queue.md b/stdlib/queue.md index a2707b2b5e..5b40be9376 100644 --- a/stdlib/queue.md +++ b/stdlib/queue.md @@ -14,7 +14,7 @@ No other changes yet. ```grain -include "queue" +from "queue" include Queue ``` ## Types diff --git a/stdlib/random.gr b/stdlib/random.gr index a2015d5d36..449209b215 100644 --- a/stdlib/random.gr +++ b/stdlib/random.gr @@ -1,20 +1,20 @@ /** * Pseudo-random number generation. * - * @example include "random" + * @example from "random" include Random * * @since v0.5.0 */ module Random -include "sys/random" as WasiRandom -include "result" -include "uint32" -include "uint64" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/dataStructures" as DS +from "sys/random" include Random as WasiRandom +from "result" include Result +from "uint32" include Uint32 +from "uint64" include Uint64 +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures as DS abstract record Random { seed: Uint64, diff --git a/stdlib/random.md b/stdlib/random.md index 23deb09a3c..37af134761 100644 --- a/stdlib/random.md +++ b/stdlib/random.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "random" +from "random" include Random ``` ## Types diff --git a/stdlib/range.gr b/stdlib/range.gr index 5bcd22b382..15c8530746 100644 --- a/stdlib/range.gr +++ b/stdlib/range.gr @@ -6,7 +6,7 @@ * All functions in this module treat ranges as exclusive, but inclusive versions * of all APIs are available in the `Inclusive` submodule. * - * @example include "range" + * @example from "range" include Range * * @since v0.3.0 * @history v0.6.0: Treats all ranges as exclusive diff --git a/stdlib/range.md b/stdlib/range.md index 0a04312225..cfe95e3dd9 100644 --- a/stdlib/range.md +++ b/stdlib/range.md @@ -22,7 +22,7 @@ of all APIs are available in the `Inclusive` submodule. ```grain -include "range" +from "range" include Range ``` ## Values diff --git a/stdlib/rational.gr b/stdlib/rational.gr index cf7bde3702..aa0b2194e4 100644 --- a/stdlib/rational.gr +++ b/stdlib/rational.gr @@ -1,6 +1,6 @@ /** * Utilities for working with the Rational type. - * @example include "rational" + * @example from "rational" include Rational * * @example 1/2r * @example 3/4r @@ -9,9 +9,9 @@ */ module Rational -include "runtime/unsafe/wasmi32" -include "runtime/exception" -include "runtime/numbers" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToRational as fromNumber, coerceRationalToNumber as toNumber, diff --git a/stdlib/rational.md b/stdlib/rational.md index b8ebfa183d..13a1ae2135 100644 --- a/stdlib/rational.md +++ b/stdlib/rational.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "rational" +from "rational" include Rational ``` ```grain diff --git a/stdlib/regex.gr b/stdlib/regex.gr index f41dcce564..a722b7d282 100644 --- a/stdlib/regex.gr +++ b/stdlib/regex.gr @@ -1,7 +1,7 @@ /** * Regular Expressions. * - * @example include "regex" + * @example from "regex" include Regex * * @since 0.4.3 */ @@ -13,14 +13,14 @@ module Regex which is licensed under Apache 2.0. Racket's regular expression engine is itself inspired by the Spencer engine, as found in Tcl. */ -include "array" -include "char" -include "list" -include "map" -include "option" -include "result" -include "string" -include "number" +from "array" include Array +from "char" include Char +from "list" include List +from "map" include Map +from "option" include Option +from "result" include Result +from "string" include String +from "number" include Number use Number.{ min, max } /* diff --git a/stdlib/regex.md b/stdlib/regex.md index cfe71c534b..ff71249a71 100644 --- a/stdlib/regex.md +++ b/stdlib/regex.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "regex" +from "regex" include Regex ``` ## Types diff --git a/stdlib/result.gr b/stdlib/result.gr index 06361ea1a4..1d35a5c23b 100644 --- a/stdlib/result.gr +++ b/stdlib/result.gr @@ -4,7 +4,7 @@ * The Result type is an enum that represents the possibility of a success case (with the `Ok` variant), * or an error case (with the `Err` variant). Use a Result as the return type of a function that may return an error. * - * @example include "result" + * @example from "result" include Result * * @example let success = Ok((x) => 1 + x) // Creates a successful Result containing (x) => 1 + x * @example let failure = Err("Something bad happened") // Creates an unsuccessful Result containing "Something bad happened" diff --git a/stdlib/result.md b/stdlib/result.md index 106df196c8..35be22f829 100644 --- a/stdlib/result.md +++ b/stdlib/result.md @@ -13,7 +13,7 @@ No other changes yet. ```grain -include "result" +from "result" include Result ``` ```grain diff --git a/stdlib/runtime/atof/common.gr b/stdlib/runtime/atof/common.gr index 80aa5afc4a..b0840bd83b 100644 --- a/stdlib/runtime/atof/common.gr +++ b/stdlib/runtime/atof/common.gr @@ -30,14 +30,14 @@ */ module Common -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf64" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, newInt64, newFloat64 } -include "runtime/numberUtils" +from "runtime/numberUtils" include NumberUtils use NumberUtils.{ get_POWERS10 } -include "./table" +from "./table" include Table use Table.{ get_F64_POWERS10_FAST_PATH, get_POWERS5 } primitive (&&) = "@and" diff --git a/stdlib/runtime/atof/decimal.gr b/stdlib/runtime/atof/decimal.gr index 14de5b11cb..088f0e0204 100644 --- a/stdlib/runtime/atof/decimal.gr +++ b/stdlib/runtime/atof/decimal.gr @@ -30,13 +30,13 @@ */ module Decimal -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, allocateBytes } -include "./common" +from "./common" include Common use Common.{ _CHAR_CODE_UNDERSCORE, _CHAR_CODE_PLUS, diff --git a/stdlib/runtime/atof/lemire.gr b/stdlib/runtime/atof/lemire.gr index e41cf3fa87..b459a650ff 100644 --- a/stdlib/runtime/atof/lemire.gr +++ b/stdlib/runtime/atof/lemire.gr @@ -30,15 +30,15 @@ */ module Lemire -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, newInt64, newFloat64 } -include "./table" +from "./table" include Table use Table.{ get_POWERS5 } -include "./common" +from "./common" include Common use Common.{ _SMALLEST_POWER_OF_FIVE, _LARGEST_POWER_OF_FIVE, diff --git a/stdlib/runtime/atof/parse.gr b/stdlib/runtime/atof/parse.gr index fcdf9ff9fe..8a2e6bc365 100644 --- a/stdlib/runtime/atof/parse.gr +++ b/stdlib/runtime/atof/parse.gr @@ -28,13 +28,13 @@ */ module Parse -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf64" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, newInt64, newFloat64 } -include "./common" +from "./common" include Common use Common.{ _CHAR_CODE_UNDERSCORE, _CHAR_CODE_PLUS, @@ -63,9 +63,9 @@ use Common.{ fpInf, } -include "./lemire" +from "./lemire" include Lemire use Lemire.{ computeFloat } -include "./slow" +from "./slow" include Slow use Slow.{ parseLongMantissa } // Try to parse 8 digits at a time: diff --git a/stdlib/runtime/atof/slow.gr b/stdlib/runtime/atof/slow.gr index 4eb0466f95..f7a180f79b 100644 --- a/stdlib/runtime/atof/slow.gr +++ b/stdlib/runtime/atof/slow.gr @@ -30,13 +30,13 @@ module Slow //! Slow, fallback algorithm for cases the Eisel-Lemire algorithm cannot round. -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, newInt64 } -include "./common" +from "./common" include Common use Common.{ type BiasedFp, fpZero, @@ -47,7 +47,7 @@ use Common.{ _MANTISSA_EXPLICIT_BITS_32, _MANTISSA_EXPLICIT_BITS_64, } -include "./decimal" +from "./decimal" include Decimal use Decimal.{ parseDecimal, _DECIMAL_POINT_RANGE } @unsafe diff --git a/stdlib/runtime/atof/table.gr b/stdlib/runtime/atof/table.gr index c43ab01fbc..d91ed7afaa 100644 --- a/stdlib/runtime/atof/table.gr +++ b/stdlib/runtime/atof/table.gr @@ -1,10 +1,10 @@ /* grainc-flags --no-pervasives */ module Table -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf64" -include "runtime/unsafe/memory" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/unsafe/memory" include Memory @unsafe let mut _F64_POWERS10_FAST_PATH = -1n diff --git a/stdlib/runtime/atoi/parse.gr b/stdlib/runtime/atoi/parse.gr index 4990ebb64c..2171bc24a1 100644 --- a/stdlib/runtime/atoi/parse.gr +++ b/stdlib/runtime/atoi/parse.gr @@ -1,7 +1,7 @@ /* grainc-flags --no-pervasives */ module Parse -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -13,11 +13,11 @@ use WasmI32.{ (!=), (&), } -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/unsafe/tags" -include "runtime/bigint" as BI -include "runtime/numbers" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/bigint" include Bigint as BI +from "runtime/numbers" include Numbers use Numbers.{ reducedInteger } primitive (&&) = "@and" diff --git a/stdlib/runtime/bigint.gr b/stdlib/runtime/bigint.gr index 4b791035d7..931aaaf263 100644 --- a/stdlib/runtime/bigint.gr +++ b/stdlib/runtime/bigint.gr @@ -15,17 +15,17 @@ The following is the copyright notice from the `nim-lang/bigints` project (MIT L Copyright 2019 Dennis Felsing */ -include "runtime/unsafe/memory" -include "runtime/unsafe/tags" -include "runtime/unsafe/constants" +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/unsafe/constants" include Constants use Constants.{ _UMAX_I64, _SMAX32_I64, _SMAX_I64, _SMAX_I32 } -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" -include "runtime/exception" -include "runtime/dataStructures" as DS -include "runtime/utils/printing" as RPrint +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/exception" include Exception +from "runtime/dataStructures" include DataStructures as DS +from "runtime/utils/printing" include Printing as RPrint // things we need which are missing due to --no-pervasives: primitive (!) = "@not" diff --git a/stdlib/runtime/compare.gr b/stdlib/runtime/compare.gr index 7132ee3047..28b3f700ec 100644 --- a/stdlib/runtime/compare.gr +++ b/stdlib/runtime/compare.gr @@ -1,7 +1,7 @@ /* grainc-flags --no-pervasives */ module Compare -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (==), (!=), @@ -17,13 +17,13 @@ use WasmI32.{ (<<), (>>>), } -include "runtime/unsafe/wasmi64" as WasmI64 -include "runtime/unsafe/wasmf32" as WasmF32 -include "runtime/unsafe/memory" as Memory -include "runtime/unsafe/tags" as Tags -include "runtime/dataStructures" as DataStructures +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber } -include "runtime/numbers" as Numbers +from "runtime/numbers" include Numbers use Numbers.{ isNumber, cmp as numberCompare } primitive (!) = "@not" diff --git a/stdlib/runtime/debugPrint.gr b/stdlib/runtime/debugPrint.gr index 73f7ee42bf..b314e3ab91 100644 --- a/stdlib/runtime/debugPrint.gr +++ b/stdlib/runtime/debugPrint.gr @@ -1,10 +1,10 @@ module DebugPrint -include "runtime/numberUtils" as Utils -include "runtime/unsafe/wasmi32" +from "runtime/numberUtils" include NumberUtils as Utils +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+) } -include "runtime/unsafe/wasmf64" -include "runtime/unsafe/memory" +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/unsafe/memory" include Memory foreign wasm fd_write: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1" diff --git a/stdlib/runtime/equal.gr b/stdlib/runtime/equal.gr index 3a414b854c..a0023eab5a 100644 --- a/stdlib/runtime/equal.gr +++ b/stdlib/runtime/equal.gr @@ -1,13 +1,13 @@ /* grainc-flags --no-pervasives */ module Equal -include "runtime/unsafe/memory" -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (==), (!=), (&), (^), (+), (-), (*), (<), remS as (%), (<<) } -include "runtime/unsafe/wasmi64" as WasmI64 -include "runtime/unsafe/wasmf32" as WasmF32 -include "runtime/unsafe/tags" as Tags -include "runtime/numbers" as Numbers +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/tags" include Tags +from "runtime/numbers" include Numbers use Numbers.{ isNumber, numberEqual } primitive (!) = "@not" diff --git a/stdlib/runtime/exception.gr b/stdlib/runtime/exception.gr index a86552874b..197649c082 100644 --- a/stdlib/runtime/exception.gr +++ b/stdlib/runtime/exception.gr @@ -1,7 +1,7 @@ /* grainc-flags --compilation-mode=runtime */ module Exception -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (==), (+), (-) } foreign wasm fd_write: diff --git a/stdlib/runtime/gc.gr b/stdlib/runtime/gc.gr index 8b231bf167..66644dd21f 100644 --- a/stdlib/runtime/gc.gr +++ b/stdlib/runtime/gc.gr @@ -19,9 +19,9 @@ module GC * userPtr : The pointer returned (and referenced by) to the Grain runtime */ -include "runtime/malloc" as Malloc -include "runtime/unsafe/tags" as Tags -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/malloc" include Malloc +from "runtime/unsafe/tags" include Tags +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (*), (&), (==), (!=) } // Using foreigns directly here to avoid cyclic dependency diff --git a/stdlib/runtime/malloc.gr b/stdlib/runtime/malloc.gr index fb9fb91dcc..10a77ad72f 100644 --- a/stdlib/runtime/malloc.gr +++ b/stdlib/runtime/malloc.gr @@ -7,7 +7,7 @@ module Malloc * from pages 185-188 of K&R C (2nd edition). */ -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -21,7 +21,7 @@ use WasmI32.{ (==), (!=), } -include "runtime/exception" +from "runtime/exception" include Exception primitive memorySize = "@wasm.memory_size" primitive memoryGrow = "@wasm.memory_grow" diff --git a/stdlib/runtime/numberUtils.gr b/stdlib/runtime/numberUtils.gr index 01ec2cd81c..e457072ae6 100644 --- a/stdlib/runtime/numberUtils.gr +++ b/stdlib/runtime/numberUtils.gr @@ -5,8 +5,8 @@ module NumberUtils * This file was inspired by AssemblyScript's std/assembly/util/number.ts */ -include "runtime/unsafe/memory" as Memory -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (==), (!=), @@ -17,10 +17,10 @@ use WasmI32.{ (|), // no signed imports, as care should be taken to use signed or unsigned operators } -include "runtime/unsafe/wasmi64" as WasmI64 -include "runtime/unsafe/wasmf64" as WasmF64 -include "runtime/exception" as Exception -include "runtime/dataStructures" as DataStructures +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/exception" include Exception +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateString } primitive (!) = "@not" diff --git a/stdlib/runtime/numbers.gr b/stdlib/runtime/numbers.gr index 2445e9aaed..09d63de3e1 100644 --- a/stdlib/runtime/numbers.gr +++ b/stdlib/runtime/numbers.gr @@ -1,12 +1,12 @@ /* grainc-flags --no-pervasives */ module Numbers -include "runtime/unsafe/memory" as Memory -include "runtime/unsafe/tags" as Tags -include "runtime/exception" as Exception -include "runtime/bigint" as BI +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/exception" include Exception +from "runtime/bigint" include Bigint as BI -include "runtime/unsafe/constants" as Constants +from "runtime/unsafe/constants" include Constants use Constants.{ _SMIN8_I32, _SMAX8_I32, @@ -27,10 +27,10 @@ use Constants.{ _UMAX32_I64 as _U32_MAX, _UMIN32_I64 as _U32_MIN, } -include "runtime/unsafe/wasmi32" as WasmI32 -include "runtime/unsafe/wasmi64" as WasmI64 -include "runtime/unsafe/wasmf32" as WasmF32 -include "runtime/unsafe/wasmf64" as WasmF64 +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 primitive (!) = "@not" primitive (&&) = "@and" @@ -41,7 +41,7 @@ primitive ignore = "@ignore" exception UnknownNumberTag exception InvariantViolation -include "runtime/dataStructures" as DataStructures +from "runtime/dataStructures" include DataStructures use DataStructures.{ newRational, newInt32, diff --git a/stdlib/runtime/string.gr b/stdlib/runtime/string.gr index f83a75fdf2..0c78ac178d 100644 --- a/stdlib/runtime/string.gr +++ b/stdlib/runtime/string.gr @@ -1,7 +1,7 @@ /* grainc-flags --no-pervasives */ module String -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -20,15 +20,15 @@ use WasmI32.{ (<=), (<), } -include "runtime/unsafe/wasmi64" as WasmI64 -include "runtime/unsafe/wasmf32" as WasmF32 -include "runtime/unsafe/wasmf64" as WasmF64 -include "runtime/bigint" as BI -include "runtime/unsafe/memory" as Memory -include "runtime/unsafe/tags" as Tags -include "runtime/numberUtils" as NumberUtils - -include "runtime/dataStructures" as DataStructures +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/bigint" include Bigint as BI +from "runtime/unsafe/memory" include Memory +from "runtime/unsafe/tags" include Tags +from "runtime/numberUtils" include NumberUtils + +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateString, allocateArray, untagSimpleNumber } foreign wasm fd_write: diff --git a/stdlib/runtime/unsafe/conv.gr b/stdlib/runtime/unsafe/conv.gr index 2657df9b7c..27b1cdfe8f 100644 --- a/stdlib/runtime/unsafe/conv.gr +++ b/stdlib/runtime/unsafe/conv.gr @@ -1,10 +1,10 @@ module Conv -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/wasmf32" -include "runtime/unsafe/wasmf64" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/wasmf32" include WasmF32 +from "runtime/unsafe/wasmf64" include WasmF64 +from "runtime/dataStructures" include DataStructures use DataStructures.{ newInt32, newUint32, diff --git a/stdlib/runtime/unsafe/memory.gr b/stdlib/runtime/unsafe/memory.gr index 7ca0338365..104b96c759 100644 --- a/stdlib/runtime/unsafe/memory.gr +++ b/stdlib/runtime/unsafe/memory.gr @@ -1,9 +1,9 @@ /* grainc-flags --compilation-mode=runtime */ module Memory -include "runtime/gc" as GC +from "runtime/gc" include GC use GC.{ malloc, free, incRef, decRef } -include "runtime/unsafe/wasmi32" as WasmI32 +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (<<), (==), (!=), ltU as (<) } provide { malloc, free, incRef, decRef } diff --git a/stdlib/runtime/utils/printing.gr b/stdlib/runtime/utils/printing.gr index ed0aa8b786..328f87aca3 100644 --- a/stdlib/runtime/utils/printing.gr +++ b/stdlib/runtime/utils/printing.gr @@ -2,9 +2,9 @@ module Printing // Printing utilities for runtime code (primarily for debugging) -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/memory" -include "runtime/numberUtils" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/numberUtils" include NumberUtils foreign wasm fd_write: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1" diff --git a/stdlib/runtime/wasi.gr b/stdlib/runtime/wasi.gr index 27a38c9960..4a408e55fd 100644 --- a/stdlib/runtime/wasi.gr +++ b/stdlib/runtime/wasi.gr @@ -1,8 +1,8 @@ /* grainc-flags --no-gc */ module Wasi -include "runtime/unsafe/wasmi32" -include "exception" +from "runtime/unsafe/wasmi32" include WasmI32 +from "exception" include Exception // env provide foreign wasm args_get: diff --git a/stdlib/set.gr b/stdlib/set.gr index 8636b7921d..276c74198a 100644 --- a/stdlib/set.gr +++ b/stdlib/set.gr @@ -2,15 +2,15 @@ * A Set is an unordered collection of unique values. Operations on a Set mutate the internal state, so it never needs to be re-assigned. * * An immutable set implementation is available in the `Immutable` submodule. - * @example include "set" + * @example from "set" include Set * * @since v0.3.0 */ module Set -include "list" -include "array" -include "hash" +from "list" include List +from "array" include Array +from "hash" include Hash use Hash.{ hash } record rec Bucket { diff --git a/stdlib/set.md b/stdlib/set.md index 0c3236ebe5..8e1c7492ff 100644 --- a/stdlib/set.md +++ b/stdlib/set.md @@ -12,7 +12,7 @@ No other changes yet. ```grain -include "set" +from "set" include Set ``` ## Types diff --git a/stdlib/stack.gr b/stdlib/stack.gr index 98cd327d11..aeb8d58b3f 100644 --- a/stdlib/stack.gr +++ b/stdlib/stack.gr @@ -5,14 +5,14 @@ * The default implementation is mutable, but an immutable stack * implementation is available in the `Immutable` submodule. * - * @example include "stack" + * @example from "stack" include Stack * * @since v0.3.0 */ module Stack -include "list" -include "array" +from "list" include List +from "array" include Array /** * A mutable LIFO (last-in-first-out) data structure. diff --git a/stdlib/stack.md b/stdlib/stack.md index 3f69284eab..998e85ee35 100644 --- a/stdlib/stack.md +++ b/stdlib/stack.md @@ -14,7 +14,7 @@ No other changes yet. ```grain -include "stack" +from "stack" include Stack ``` ## Types diff --git a/stdlib/string.gr b/stdlib/string.gr index 8f23d76814..77d1239ded 100644 --- a/stdlib/string.gr +++ b/stdlib/string.gr @@ -1,7 +1,7 @@ /** * Utilities for working with strings. * - * @example include "string" + * @example from "string" include String * * @since v0.2.0 * @history v0.1.0: Originally named `strings` @@ -9,12 +9,12 @@ */ module String -include "char" -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/memory" -include "runtime/exception" -include "runtime/unsafe/conv" -include "runtime/dataStructures" +from "char" include Char +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/memory" include Memory +from "runtime/exception" include Exception +from "runtime/unsafe/conv" include Conv +from "runtime/dataStructures" include DataStructures use DataStructures.{ untagSimpleNumber, tagSimpleNumber, diff --git a/stdlib/string.md b/stdlib/string.md index 70df77cabb..064fdbcff4 100644 --- a/stdlib/string.md +++ b/stdlib/string.md @@ -18,7 +18,7 @@ Utilities for working with strings. ```grain -include "string" +from "string" include String ``` ## Types diff --git a/stdlib/sys/file.gr b/stdlib/sys/file.gr index 94a7899afc..497d1c4dd4 100644 --- a/stdlib/sys/file.gr +++ b/stdlib/sys/file.gr @@ -3,11 +3,11 @@ * * Many of the functions in this module are not intended to be used directly, but rather for other libraries to be built on top of them. * - * @example include "sys/file" + * @example from "sys/file" include File */ module File -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), @@ -24,10 +24,10 @@ use WasmI32.{ (&), (|), } -include "runtime/unsafe/wasmi64" -include "runtime/wasi" -include "runtime/unsafe/memory" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/wasi" include Wasi +from "runtime/unsafe/memory" include Memory +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber, untagSimpleNumber, @@ -39,7 +39,7 @@ use DataStructures.{ allocateInt64, } -include "list" +from "list" include List /** * Represents a handle to an open file on the system. diff --git a/stdlib/sys/file.md b/stdlib/sys/file.md index df784372f4..d7eaf65878 100644 --- a/stdlib/sys/file.md +++ b/stdlib/sys/file.md @@ -7,7 +7,7 @@ Utilities for accessing the filesystem & working with files. Many of the functions in this module are not intended to be used directly, but rather for other libraries to be built on top of them. ```grain -include "sys/file" +from "sys/file" include File ``` ## Types diff --git a/stdlib/sys/process.gr b/stdlib/sys/process.gr index e4dfa76343..9fd6256853 100644 --- a/stdlib/sys/process.gr +++ b/stdlib/sys/process.gr @@ -3,15 +3,15 @@ * * This includes things like accessing environment variables and sending signals. * - * @example include "sys/process" + * @example from "sys/process" include Sys/process */ module Process -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (*), (>>), (>>>), (&), (==), (!=), (<) } -include "runtime/unsafe/memory" -include "runtime/wasi" -include "runtime/dataStructures" +from "runtime/unsafe/memory" include Memory +from "runtime/wasi" include Wasi +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber, allocateArray, allocateString } /** diff --git a/stdlib/sys/process.md b/stdlib/sys/process.md index 28d678879d..fa16661e14 100644 --- a/stdlib/sys/process.md +++ b/stdlib/sys/process.md @@ -7,7 +7,7 @@ Utilities for accessing functionality and information about the Grain program's This includes things like accessing environment variables and sending signals. ```grain -include "sys/process" +from "sys/process" include Sys/process ``` ## Types diff --git a/stdlib/sys/random.gr b/stdlib/sys/random.gr index fc100de3f0..cd6195682a 100644 --- a/stdlib/sys/random.gr +++ b/stdlib/sys/random.gr @@ -1,16 +1,16 @@ /** * System access to random values. * - * @example include "sys/random" + * @example from "sys/random" include Random */ module Random -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (==), (!=) } -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/wasi" -include "runtime/dataStructures" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/wasi" include Wasi +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagSimpleNumber, newUint32, newUint64 } /** diff --git a/stdlib/sys/random.md b/stdlib/sys/random.md index eefd33fa9c..f70e3921bd 100644 --- a/stdlib/sys/random.md +++ b/stdlib/sys/random.md @@ -5,7 +5,7 @@ title: Random System access to random values. ```grain -include "sys/random" +from "sys/random" include Random ``` ## Values diff --git a/stdlib/sys/time.gr b/stdlib/sys/time.gr index 7735292221..f95ae4e3a1 100644 --- a/stdlib/sys/time.gr +++ b/stdlib/sys/time.gr @@ -1,15 +1,15 @@ /** * Access to system clocks. * - * @example include "sys/time" + * @example from "sys/time" include Time */ module Time -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (==), (!=) } -include "runtime/unsafe/memory" -include "runtime/wasi" -include "runtime/dataStructures" +from "runtime/unsafe/memory" include Memory +from "runtime/wasi" include Wasi +from "runtime/dataStructures" include DataStructures use DataStructures.{ allocateInt64, tagSimpleNumber } @unsafe diff --git a/stdlib/sys/time.md b/stdlib/sys/time.md index 484c52f683..e8b086092a 100644 --- a/stdlib/sys/time.md +++ b/stdlib/sys/time.md @@ -5,7 +5,7 @@ title: Time Access to system clocks. ```grain -include "sys/time" +from "sys/time" include Time ``` ## Values diff --git a/stdlib/uint16.gr b/stdlib/uint16.gr index 61ea7655da..e5da731a11 100644 --- a/stdlib/uint16.gr +++ b/stdlib/uint16.gr @@ -1,19 +1,19 @@ /** * Utilities for working with the Uint16 type. - * @example include "uint16" + * @example from "uint16" include Uint16 * * @since v0.6.0 */ module Uint16 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (*), (&), (|), (^), (<<), (>>>), (==), (!=) } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToUint16 as fromNumber, coerceUint16ToNumber as toNumber, } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagUint16, untagUint16 } @unsafe diff --git a/stdlib/uint16.md b/stdlib/uint16.md index 81500f56ab..ce6f4f2c38 100644 --- a/stdlib/uint16.md +++ b/stdlib/uint16.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "uint16" +from "uint16" include Uint16 ``` ## Values diff --git a/stdlib/uint32.gr b/stdlib/uint32.gr index db21dd9ea9..1485e7b91c 100644 --- a/stdlib/uint32.gr +++ b/stdlib/uint32.gr @@ -1,19 +1,19 @@ /** * Utilities for working with the Uint32 type. - * @example include "uint32" + * @example from "uint32" include Uint32 * * @since v0.6.0 */ module Uint32 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (*), (&), (|), (^), (<<), (>>>), (==), (!=) } -include "runtime/unsafe/wasmi64" -include "runtime/unsafe/memory" -include "runtime/exception" -include "runtime/numbers" +from "runtime/unsafe/wasmi64" include WasmI64 +from "runtime/unsafe/memory" include Memory +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ reducedUnsignedInteger, coerceNumberToUnsignedWasmI32 } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newUint32 } @unsafe diff --git a/stdlib/uint32.md b/stdlib/uint32.md index 1687c08329..f8cf24fd2b 100644 --- a/stdlib/uint32.md +++ b/stdlib/uint32.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "uint32" +from "uint32" include Uint32 ``` ## Values diff --git a/stdlib/uint64.gr b/stdlib/uint64.gr index 17154834b9..61daea89fa 100644 --- a/stdlib/uint64.gr +++ b/stdlib/uint64.gr @@ -1,19 +1,19 @@ /** * Utilities for working with the Uint64 type. - * @example include "uint64" + * @example from "uint64" include Uint64 * * @since v0.6.0 */ module Uint64 -include "runtime/unsafe/wasmi32" -include "runtime/unsafe/wasmi64" +from "runtime/unsafe/wasmi32" include WasmI32 +from "runtime/unsafe/wasmi64" include WasmI64 use WasmI64.{ (==), (!=), (&), (|), (^), (+), (-), (*), (<<), (>>>) } -include "runtime/unsafe/memory" -include "runtime/exception" -include "runtime/numbers" +from "runtime/unsafe/memory" include Memory +from "runtime/exception" include Exception +from "runtime/numbers" include Numbers use Numbers.{ reducedUnsignedInteger, coerceNumberToUnsignedWasmI64 } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ newUint64 } // First 8 bytes of 64-bit unsigned int are heap tag and 32 bits of padding diff --git a/stdlib/uint64.md b/stdlib/uint64.md index 857437cc01..1455274114 100644 --- a/stdlib/uint64.md +++ b/stdlib/uint64.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "uint64" +from "uint64" include Uint64 ``` ## Values diff --git a/stdlib/uint8.gr b/stdlib/uint8.gr index 7c98975439..8ee5c31fb4 100644 --- a/stdlib/uint8.gr +++ b/stdlib/uint8.gr @@ -1,19 +1,19 @@ /** * Utilities for working with the Uint8 type. - * @example include "uint8" + * @example from "uint8" include Uint8 * * @since v0.6.0 */ module Uint8 -include "runtime/unsafe/wasmi32" +from "runtime/unsafe/wasmi32" include WasmI32 use WasmI32.{ (+), (-), (*), (&), (|), (^), (<<), (>>>), (==), (!=) } -include "runtime/numbers" +from "runtime/numbers" include Numbers use Numbers.{ coerceNumberToUint8 as fromNumber, coerceUint8ToNumber as toNumber, } -include "runtime/dataStructures" +from "runtime/dataStructures" include DataStructures use DataStructures.{ tagUint8, untagUint8 } @unsafe diff --git a/stdlib/uint8.md b/stdlib/uint8.md index df0534d91f..c78ece8e95 100644 --- a/stdlib/uint8.md +++ b/stdlib/uint8.md @@ -10,7 +10,7 @@ No other changes yet. ```grain -include "uint8" +from "uint8" include Uint8 ``` ## Values