add standard library .roc files

This commit is contained in:
Folkert 2022-03-23 17:13:16 +01:00
parent 750fbf2dcf
commit ca16099e83
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
10 changed files with 444 additions and 0 deletions

View file

@ -2,4 +2,5 @@
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)]
pub mod bitcode;
pub mod standard_library;
pub mod std;

View file

@ -0,0 +1,28 @@
use roc_module::symbol::ModuleId;
#[inline(always)]
pub fn module_source(module_id: ModuleId) -> &'static str {
match module_id {
ModuleId::RESULT => RESULT,
ModuleId::NUM => NUM,
ModuleId::STR => STR,
ModuleId::LIST => LIST,
ModuleId::DICT => DICT,
ModuleId::SET => SET,
ModuleId::BOX => BOX,
ModuleId::BOOL => BOOL,
_ => panic!(
"ModuleId {:?} is not part of the standard library",
module_id
),
}
}
const RESULT: &str = include_str!("../standard_library/Result.roc");
const NUM: &str = include_str!("../standard_library/Num.roc");
const STR: &str = include_str!("../standard_library/Str.roc");
const LIST: &str = include_str!("../standard_library/List.roc");
const DICT: &str = include_str!("../standard_library/Dict.roc");
const SET: &str = include_str!("../standard_library/Set.roc");
const BOX: &str = include_str!("../standard_library/Box.roc");
const BOOL: &str = include_str!("../standard_library/Bool.roc");