mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-15 17:40:16 +00:00
Create can::module::ModuleParams for convenience
This commit is contained in:
parent
e80e3e5b2d
commit
519ff56a85
12 changed files with 164 additions and 137 deletions
|
@ -4,7 +4,7 @@ use crate::{aliases::Aliases, solve};
|
|||
use roc_can::abilities::{AbilitiesStore, ResolvedImpl};
|
||||
use roc_can::constraint::{Constraint, Constraints};
|
||||
use roc_can::expr::PendingDerives;
|
||||
use roc_can::module::{ExposedByModule, ResolvedImplementations, RigidVariables};
|
||||
use roc_can::module::{ExposedByModule, ModuleParams, ResolvedImplementations, RigidVariables};
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_collections::VecMap;
|
||||
use roc_derive::SharedDerivedModule;
|
||||
|
@ -82,7 +82,7 @@ pub struct SolveConfig<'a> {
|
|||
pub checkmate: Option<roc_checkmate::Collector>,
|
||||
|
||||
/// Module params
|
||||
pub params_pattern: Option<roc_can::pattern::Pattern>,
|
||||
pub module_params: Option<ModuleParams>,
|
||||
pub module_params_vars: VecMap<ModuleId, Variable>,
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo};
|
|||
use roc_can::constraint::Constraint::{self, *};
|
||||
use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve};
|
||||
use roc_can::expected::{Expected, PExpected};
|
||||
use roc_can::module::ModuleParams;
|
||||
use roc_collections::VecMap;
|
||||
use roc_debug_flags::dbg_do;
|
||||
#[cfg(debug_assertions)]
|
||||
|
@ -130,7 +131,7 @@ fn run_help(
|
|||
exposed_by_module,
|
||||
derived_module,
|
||||
function_kind,
|
||||
params_pattern,
|
||||
module_params,
|
||||
module_params_vars,
|
||||
..
|
||||
} = config;
|
||||
|
@ -184,7 +185,7 @@ fn run_help(
|
|||
abilities_store,
|
||||
&mut obligation_cache,
|
||||
&mut awaiting_specializations,
|
||||
params_pattern,
|
||||
module_params,
|
||||
module_params_vars,
|
||||
);
|
||||
|
||||
|
@ -243,10 +244,10 @@ fn solve(
|
|||
abilities_store: &mut AbilitiesStore,
|
||||
obligation_cache: &mut ObligationCache,
|
||||
awaiting_specializations: &mut AwaitingSpecializations,
|
||||
params_pattern: Option<roc_can::pattern::Pattern>,
|
||||
module_params: Option<ModuleParams>,
|
||||
module_params_vars: VecMap<ModuleId, Variable>,
|
||||
) -> State {
|
||||
let scope = Scope::new(params_pattern);
|
||||
let scope = Scope::new(module_params);
|
||||
|
||||
let initial = Work::Constraint {
|
||||
scope: &scope.clone(),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use roc_can::module::ModuleParams;
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_types::subs::Variable;
|
||||
|
||||
|
@ -9,29 +10,19 @@ pub struct Scope {
|
|||
}
|
||||
|
||||
impl Scope {
|
||||
pub fn new(params_pattern: Option<roc_can::pattern::Pattern>) -> Self {
|
||||
match params_pattern {
|
||||
Some(params_pattern) => match params_pattern {
|
||||
roc_can::pattern::Pattern::RecordDestructure {
|
||||
whole_var: _,
|
||||
ext_var: _,
|
||||
destructs,
|
||||
} => {
|
||||
let mut symbols = Vec::with_capacity(destructs.len());
|
||||
let mut variables = Vec::with_capacity(destructs.len());
|
||||
pub fn new(opt_module_params: Option<ModuleParams>) -> Self {
|
||||
match opt_module_params {
|
||||
Some(module_params) => {
|
||||
let mut symbols = Vec::with_capacity(module_params.destructs.len());
|
||||
let mut variables = Vec::with_capacity(module_params.destructs.len());
|
||||
|
||||
for destruct in destructs {
|
||||
symbols.push(destruct.value.symbol);
|
||||
variables.push(destruct.value.var);
|
||||
}
|
||||
|
||||
Self { symbols, variables }
|
||||
for destruct in module_params.destructs {
|
||||
symbols.push(destruct.value.symbol);
|
||||
variables.push(destruct.value.var);
|
||||
}
|
||||
_ => unreachable!(
|
||||
"other pattern types should have parsed: {:?}",
|
||||
params_pattern
|
||||
),
|
||||
},
|
||||
|
||||
Self { symbols, variables }
|
||||
}
|
||||
None => Self {
|
||||
symbols: Vec::default(),
|
||||
variables: Vec::default(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue