roc/crates/ast/src/module.rs
Ayaz Hafiz 44c4797d9a
Parameterize program solving on a FunctionKind
This new flag determines whether we should introduce a new kind to
represent lambda sets, or whether lambdas should be erased. The latter
is not yet implemented.
2023-07-12 13:53:50 -05:00

33 lines
1.2 KiB
Rust

use bumpalo::Bump;
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, Threading};
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::DEFAULT_PALETTE;
use roc_target::TargetInfo;
use std::path::Path;
pub fn load_module(
src_file: &Path,
roc_cache_dir: RocCacheDir<'_>,
threading: Threading,
) -> LoadedModule {
let load_config = LoadConfig {
target_info: TargetInfo::default_x86_64(), // editor only needs type info, so this is unused
function_kind: roc_solve::FunctionKind::LambdaSet, // TODO the editor may need to dynamically change this
render: roc_reporting::report::RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,
threading,
exec_mode: ExecutionMode::Check,
};
let arena = Bump::new();
let loaded =
roc_load::load_and_typecheck(&arena, src_file.to_path_buf(), roc_cache_dir, load_config);
match loaded {
Ok(x) => x,
Err(roc_load::LoadingProblem::FormattedReport(report)) => {
panic!("Failed to load module from src_file: {src_file:?}. Report: {report}");
}
Err(e) => panic!("Failed to load module from src_file {src_file:?}: {e:?}"),
}
}