mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
make rigid variable introducion more obvious
This commit is contained in:
parent
97742b3238
commit
15ac77567a
2 changed files with 18 additions and 8 deletions
|
@ -26,13 +26,19 @@ pub struct Module {
|
||||||
pub referenced_values: MutSet<Symbol>,
|
pub referenced_values: MutSet<Symbol>,
|
||||||
pub referenced_types: MutSet<Symbol>,
|
pub referenced_types: MutSet<Symbol>,
|
||||||
pub aliases: MutMap<Symbol, Alias>,
|
pub aliases: MutMap<Symbol, Alias>,
|
||||||
pub rigid_variables: MutMap<Variable, Lowercase>,
|
pub rigid_variables: RigidVariables,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct RigidVariables {
|
||||||
|
pub named: MutMap<Variable, Lowercase>,
|
||||||
|
pub wildcards: MutSet<Variable>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModuleOutput {
|
pub struct ModuleOutput {
|
||||||
pub aliases: MutMap<Symbol, Alias>,
|
pub aliases: MutMap<Symbol, Alias>,
|
||||||
pub rigid_variables: MutMap<Variable, Lowercase>,
|
pub rigid_variables: RigidVariables,
|
||||||
pub declarations: Vec<Declaration>,
|
pub declarations: Vec<Declaration>,
|
||||||
pub exposed_imports: MutMap<Symbol, Variable>,
|
pub exposed_imports: MutMap<Symbol, Variable>,
|
||||||
pub lookups: Vec<(Symbol, Variable, Region)>,
|
pub lookups: Vec<(Symbol, Variable, Region)>,
|
||||||
|
@ -169,7 +175,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut lookups = Vec::with_capacity(num_deps);
|
let mut lookups = Vec::with_capacity(num_deps);
|
||||||
let mut rigid_variables = MutMap::default();
|
let mut rigid_variables = RigidVariables::default();
|
||||||
|
|
||||||
// Exposed values are treated like defs that appear before any others, e.g.
|
// Exposed values are treated like defs that appear before any others, e.g.
|
||||||
//
|
//
|
||||||
|
@ -249,11 +255,11 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var, lowercase) in output.introduced_variables.name_by_var {
|
for (var, lowercase) in output.introduced_variables.name_by_var {
|
||||||
rigid_variables.insert(var, lowercase.clone());
|
rigid_variables.named.insert(var, lowercase.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
for var in output.introduced_variables.wildcards {
|
for var in output.introduced_variables.wildcards {
|
||||||
rigid_variables.insert(var, "*".into());
|
rigid_variables.wildcards.insert(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut referenced_values = MutSet::default();
|
let mut referenced_values = MutSet::default();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::solve;
|
use crate::solve;
|
||||||
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
|
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
|
||||||
|
use roc_can::module::RigidVariables;
|
||||||
use roc_collections::all::MutMap;
|
use roc_collections::all::MutMap;
|
||||||
use roc_module::ident::Lowercase;
|
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
use roc_types::solved_types::{Solved, SolvedType};
|
use roc_types::solved_types::{Solved, SolvedType};
|
||||||
use roc_types::subs::{StorageSubs, Subs, Variable};
|
use roc_types::subs::{StorageSubs, Subs, Variable};
|
||||||
|
@ -29,15 +29,19 @@ pub struct SolvedModule {
|
||||||
pub fn run_solve(
|
pub fn run_solve(
|
||||||
constraints: &Constraints,
|
constraints: &Constraints,
|
||||||
constraint: ConstraintSoa,
|
constraint: ConstraintSoa,
|
||||||
rigid_variables: MutMap<Variable, Lowercase>,
|
rigid_variables: RigidVariables,
|
||||||
mut subs: Subs,
|
mut subs: Subs,
|
||||||
) -> (Solved<Subs>, solve::Env, Vec<solve::TypeError>) {
|
) -> (Solved<Subs>, solve::Env, Vec<solve::TypeError>) {
|
||||||
let env = solve::Env::default();
|
let env = solve::Env::default();
|
||||||
|
|
||||||
for (var, name) in rigid_variables {
|
for (var, name) in rigid_variables.named {
|
||||||
subs.rigid_var(var, name);
|
subs.rigid_var(var, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for var in rigid_variables.wildcards {
|
||||||
|
subs.rigid_var(var, "*".into());
|
||||||
|
}
|
||||||
|
|
||||||
// Now that the module is parsed, canonicalized, and constrained,
|
// Now that the module is parsed, canonicalized, and constrained,
|
||||||
// we need to type check it.
|
// we need to type check it.
|
||||||
let mut problems = Vec::new();
|
let mut problems = Vec::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue