Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: enable concise top-level imports #435

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions src/lib.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

import Array_ "Array";
import AssocList_ "AssocList";
import Blob_ "Blob";
import Bool_ "Bool";
import Buffer_ "Buffer";
import CertifiedData_ "CertifiedData";
import Char_ "Char";
import Debug_ "Debug";
import Deque_ "Deque";
import Error_ "Error";
import Float_ "Float";
import Func_ "Func";
import Hash_ "Hash";
import HashMap_ "HashMap";
import Heap_ "Heap";
import Int_ "Int";
import Int16_ "Int16";
import Int32_ "Int32";
import Int64_ "Int64";
import Int8_ "Int8";
import Iter_ "Iter";
import IterType_ "IterType";
import List_ "List";
import Nat_ "Nat";
import Nat16_ "Nat16";
import Nat32_ "Nat32";
import Nat64_ "Nat64";
import Nat8_ "Nat8";
import None_ "None";
import Option_ "Option";
import Order_ "Order";
import Prelude_ "Prelude";
import Principal_ "Principal";
import RBTree_ "RBTree";
import Random_ "Random";
import Result_ "Result";
import Stack_ "Stack";
import Text_ "Text";
import Time_ "Time";
import Trie_ "Trie";
import TrieMap_ "TrieMap";
import TrieSet_ "TrieSet";

module Base {
public let Array = Array_;
public let AssocList = AssocList_;
public let Blob = Blob_;
public let Bool = Bool_;
public let Buffer = Buffer_;
public let CertifiedData = CertifiedData_;
public let Char = Char_;
public let Debug = Debug_;
public let Deque = Deque_;
public let Error = Error_;
public let Float = Float_;
public let Func = Func_;
public let Hash = Hash_;
public let HashMap = HashMap_;
public let Heap = Heap_;
public let Int = Int_;
public let Int16 = Int16_;
public let Int32 = Int32_;
public let Int64 = Int64_;
public let Int8 = Int8_;
public let Iter = Iter_;
public let IterType = IterType_;
public let List = List_;
public let Nat = Nat_;
public let Nat16 = Nat16_;
public let Nat32 = Nat32_;
public let Nat64 = Nat64_;
public let Nat8 = Nat8_;
public let None = None_;
public let Option = Option_;
public let Order = Order_;
public let Prelude = Prelude_;
public let Principal = Principal_;
public let RBTree = RBTree_;
public let Random = Random_;
public let Result = Result_;
public let Stack = Stack_;
public let Text = Text_;
public let Time = Time_;
public let Trie = Trie_;
public let TrieMap = TrieMap_;
public let TrieSet = TrieSet_;
}
28 changes: 28 additions & 0 deletions utils/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require("fs");
const path = require("path");

const exclude = [
"ExperimentalCycles",
"ExperimentalInternetComputer",
"ExperimentalStableMemory",
];

const directory = path.resolve(__dirname, "../src");

const names = fs
.readdirSync(directory)
.filter((f) => f.endsWith(".mo") && f !== "lib.mo")
.map((f) => f.slice(0, -".mo".length))
.filter((n) => !exclude.includes(n));

const libSource = `
${names.map((n) => `import ${n}_ "${n}";`).join("\n")}

module Base {
${names.map((n) => ` public let ${n} = ${n}_;`).join("\n")}
}
`;

fs.writeFileSync(path.join(directory, "lib.mo"), libSource);

console.log(libSource);