Import all types from Encode by default

This commit is contained in:
Ayaz Hafiz 2022-09-21 10:10:11 -05:00
parent 7e5ff4883f
commit 454f3634fd
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 15 additions and 1 deletions

View file

@ -80,6 +80,8 @@ const MODULE_SEPARATOR: char = '.';
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
/// TODO: how can we populate these at compile/runtime from the standard library?
/// Consider updating the macro in symbol to do this?
const PRELUDE_TYPES: [(&str, Symbol); 33] = [
("Num", Symbol::NUM_NUM),
("Int", Symbol::NUM_INT),
@ -116,6 +118,12 @@ const PRELUDE_TYPES: [(&str, Symbol); 33] = [
("Dec", Symbol::NUM_DEC),
];
const MODULE_ENCODE_TYPES: &[(&str, Symbol)] = &[
("Encoder", Symbol::ENCODE_ENCODER),
("Encoding", Symbol::ENCODE_ENCODING),
("EncoderFormatting", Symbol::ENCODE_ENCODERFORMATTING),
];
macro_rules! log {
($($arg:tt)*) => (dbg_do!(ROC_PRINT_LOAD_LOG, println!($($arg)*)))
}
@ -2248,6 +2256,12 @@ fn update<'a>(
header
.imported_modules
.insert(ModuleId::ENCODE, Region::zero());
for (type_name, symbol) in MODULE_ENCODE_TYPES {
header
.exposed_imports
.insert(Ident::from(*type_name), (*symbol, Region::zero()));
}
}
state

View file

@ -6494,7 +6494,7 @@ mod solve_expr {
indoc!(
r#"
app "test"
imports [Encode.{ Encoding, toEncoder }, Json]
imports [Json]
provides [main] to "./platform"
HelloWorld := {} has [Encoding {toEncoder}]