drop final suffixes

This commit is contained in:
Folkert 2022-03-02 21:30:38 +01:00
parent 828483393a
commit 38d3d3169a
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
6 changed files with 40 additions and 42 deletions

View file

@ -12,7 +12,7 @@ use roc_types::types::{AliasKind, Category};
#[must_use] #[must_use]
#[inline(always)] #[inline(always)]
pub fn add_numeric_bound_constr_soa( pub fn add_numeric_bound_constr(
constraints: &mut Constraints, constraints: &mut Constraints,
num_constraints: &mut impl Extend<Constraint>, num_constraints: &mut impl Extend<Constraint>,
num_type: Type, num_type: Type,
@ -41,7 +41,7 @@ pub fn add_numeric_bound_constr_soa(
} }
#[inline(always)] #[inline(always)]
pub fn int_literal_soa( pub fn int_literal(
constraints: &mut Constraints, constraints: &mut Constraints,
num_var: Variable, num_var: Variable,
precision_var: Variable, precision_var: Variable,
@ -53,7 +53,7 @@ pub fn int_literal_soa(
// Always add the bound first; this improves the resolved type quality in case it's an alias like "U8". // Always add the bound first; this improves the resolved type quality in case it's an alias like "U8".
let mut constrs = ArrayVec::<_, 3>::new(); let mut constrs = ArrayVec::<_, 3>::new();
let num_type = add_numeric_bound_constr_soa( let num_type = add_numeric_bound_constr(
constraints, constraints,
&mut constrs, &mut constrs,
Variable(num_var), Variable(num_var),
@ -78,7 +78,7 @@ pub fn int_literal_soa(
} }
#[inline(always)] #[inline(always)]
pub fn float_literal_soa( pub fn float_literal(
constraints: &mut Constraints, constraints: &mut Constraints,
num_var: Variable, num_var: Variable,
precision_var: Variable, precision_var: Variable,
@ -89,7 +89,7 @@ pub fn float_literal_soa(
let reason = Reason::FloatLiteral; let reason = Reason::FloatLiteral;
let mut constrs = ArrayVec::<_, 3>::new(); let mut constrs = ArrayVec::<_, 3>::new();
let num_type = add_numeric_bound_constr_soa( let num_type = add_numeric_bound_constr(
constraints, constraints,
&mut constrs, &mut constrs,
Variable(num_var), Variable(num_var),
@ -113,7 +113,7 @@ pub fn float_literal_soa(
} }
#[inline(always)] #[inline(always)]
pub fn num_literal_soa( pub fn num_literal(
constraints: &mut Constraints, constraints: &mut Constraints,
num_var: Variable, num_var: Variable,
expected: Expected<Type>, expected: Expected<Type>,
@ -123,7 +123,7 @@ pub fn num_literal_soa(
let open_number_type = crate::builtins::num_num(Type::Variable(num_var)); let open_number_type = crate::builtins::num_num(Type::Variable(num_var));
let mut constrs = ArrayVec::<_, 2>::new(); let mut constrs = ArrayVec::<_, 2>::new();
let num_type = add_numeric_bound_constr_soa( let num_type = add_numeric_bound_constr(
constraints, constraints,
&mut constrs, &mut constrs,
open_number_type, open_number_type,

View file

@ -1,6 +1,5 @@
use crate::builtins::{ use crate::builtins::{
empty_list_type, float_literal_soa, int_literal_soa, list_type, num_literal_soa, num_u32, empty_list_type, float_literal, int_literal, list_type, num_literal, num_u32, str_type,
str_type,
}; };
use crate::pattern::{constrain_pattern, PatternState}; use crate::pattern::{constrain_pattern, PatternState};
use roc_can::annotation::IntroducedVariables; use roc_can::annotation::IntroducedVariables;
@ -19,23 +18,23 @@ use roc_types::subs::Variable;
use roc_types::types::Type::{self, *}; use roc_types::types::Type::{self, *};
use roc_types::types::{AliasKind, AnnotationSource, Category, PReason, Reason, RecordField}; use roc_types::types::{AliasKind, AnnotationSource, Category, PReason, Reason, RecordField};
/// This is for constraining Defs /// This is for constraining Defs
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct Info { pub struct Info {
pub vars: Vec<Variable>, pub vars: Vec<Variable>,
pub constraints: Vec<Constraint>, pub constraints: Vec<Constraint>,
pub def_types: SendMap<Symbol, Loc<Type>>, pub def_types: SendMap<Symbol, Loc<Type>>,
} }
impl Info { impl Info {
pub fn with_capacity(capacity: usize) -> Self { pub fn with_capacity(capacity: usize) -> Self {
Info { Info {
vars: Vec::with_capacity(capacity), vars: Vec::with_capacity(capacity),
constraints: Vec::with_capacity(capacity), constraints: Vec::with_capacity(capacity),
def_types: SendMap::default(), def_types: SendMap::default(),
} }
} }
} }
pub struct Env { pub struct Env {
/// Whenever we encounter a user-defined type variable (a "rigid" var for short), /// Whenever we encounter a user-defined type variable (a "rigid" var for short),
@ -90,11 +89,11 @@ pub fn constrain_expr(
) -> Constraint { ) -> Constraint {
match expr { match expr {
&Int(var, precision, _, _, bound) => { &Int(var, precision, _, _, bound) => {
int_literal_soa(constraints, var, precision, expected, region, bound) int_literal(constraints, var, precision, expected, region, bound)
} }
&Num(var, _, _, bound) => num_literal_soa(constraints, var, expected, region, bound), &Num(var, _, _, bound) => num_literal(constraints, var, expected, region, bound),
&Float(var, precision, _, _, bound) => { &Float(var, precision, _, _, bound) => {
float_literal_soa(constraints, var, precision, expected, region, bound) float_literal(constraints, var, precision, expected, region, bound)
} }
EmptyRecord => constrain_empty_record(constraints, region, expected), EmptyRecord => constrain_empty_record(constraints, region, expected),
Expr::Record { record_var, fields } => { Expr::Record { record_var, fields } => {

View file

@ -16,8 +16,7 @@ pub enum ExposedModuleTypes {
Valid(MutMap<Symbol, SolvedType>, MutMap<Symbol, Alias>), Valid(MutMap<Symbol, SolvedType>, MutMap<Symbol, Alias>),
} }
pub fn constrain_module(
pub fn constrain_module_soa(
constraints: &mut Constraints, constraints: &mut Constraints,
declarations: &[Declaration], declarations: &[Declaration],
home: ModuleId, home: ModuleId,
@ -31,7 +30,7 @@ pub struct Import {
pub solved_type: SolvedType, pub solved_type: SolvedType,
} }
pub fn constrain_imported_values_soa( pub fn constrain_imported_values(
constraints: &mut Constraints, constraints: &mut Constraints,
imports: Vec<Import>, imports: Vec<Import>,
body_con: Constraint, body_con: Constraint,
@ -88,14 +87,14 @@ pub fn constrain_imported_values_soa(
} }
/// Run pre_constrain_imports to get imported_symbols and imported_aliases. /// Run pre_constrain_imports to get imported_symbols and imported_aliases.
pub fn constrain_imports_soa( pub fn constrain_imports(
constraints: &mut Constraints, constraints: &mut Constraints,
imported_symbols: Vec<Import>, imported_symbols: Vec<Import>,
constraint: Constraint, constraint: Constraint,
var_store: &mut VarStore, var_store: &mut VarStore,
) -> Constraint { ) -> Constraint {
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values_soa(constraints, imported_symbols, constraint, var_store); constrain_imported_values(constraints, imported_symbols, constraint, var_store);
// TODO determine what to do with those rigids // TODO determine what to do with those rigids
// for var in introduced_rigids { // for var in introduced_rigids {

View file

@ -194,7 +194,7 @@ pub fn constrain_pattern(
let num_type = builtins::num_num(Type::Variable(var)); let num_type = builtins::num_num(Type::Variable(var));
let num_type = builtins::add_numeric_bound_constr_soa( let num_type = builtins::add_numeric_bound_constr(
constraints, constraints,
&mut state.constraints, &mut state.constraints,
num_type, num_type,
@ -214,7 +214,7 @@ pub fn constrain_pattern(
&IntLiteral(num_var, precision_var, _, _, bound) => { &IntLiteral(num_var, precision_var, _, _, bound) => {
// First constraint on the free num var; this improves the resolved type quality in // First constraint on the free num var; this improves the resolved type quality in
// case the bound is an alias. // case the bound is an alias.
let num_type = builtins::add_numeric_bound_constr_soa( let num_type = builtins::add_numeric_bound_constr(
constraints, constraints,
&mut state.constraints, &mut state.constraints,
Type::Variable(num_var), Type::Variable(num_var),
@ -245,7 +245,7 @@ pub fn constrain_pattern(
&FloatLiteral(num_var, precision_var, _, _, bound) => { &FloatLiteral(num_var, precision_var, _, _, bound) => {
// First constraint on the free num var; this improves the resolved type quality in // First constraint on the free num var; this improves the resolved type quality in
// case the bound is an alias. // case the bound is an alias.
let num_type = builtins::add_numeric_bound_constr_soa( let num_type = builtins::add_numeric_bound_constr(
constraints, constraints,
&mut state.constraints, &mut state.constraints,
Type::Variable(num_var), Type::Variable(num_var),

View file

@ -10,7 +10,7 @@ use roc_can::def::Declaration;
use roc_can::module::{canonicalize_module_defs, Module}; use roc_can::module::{canonicalize_module_defs, Module};
use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet}; use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet};
use roc_constrain::module::{ use roc_constrain::module::{
constrain_imports_soa, constrain_module_soa, pre_constrain_imports, ConstrainableImports, constrain_imports, constrain_module, pre_constrain_imports, ConstrainableImports,
ExposedModuleTypes, Import, SubsByModule, ExposedModuleTypes, Import, SubsByModule,
}; };
use roc_module::ident::{Ident, ModuleName, QualifiedModuleName}; use roc_module::ident::{Ident, ModuleName, QualifiedModuleName};
@ -3091,7 +3091,7 @@ fn run_solve<'a>(
// Finish constraining the module by wrapping the existing Constraint // Finish constraining the module by wrapping the existing Constraint
// in the ones we just computed. We can do this off the main thread. // in the ones we just computed. We can do this off the main thread.
let constraint = constrain_imports_soa( let constraint = constrain_imports(
&mut constraints, &mut constraints,
imported_symbols, imported_symbols,
constraint, constraint,
@ -3113,7 +3113,7 @@ fn run_solve<'a>(
// if false { debug_assert!(constraint.validate(), "{:?}", &constraint); } // if false { debug_assert!(constraint.validate(), "{:?}", &constraint); }
let (solved_subs, solved_env, problems) = let (solved_subs, solved_env, problems) =
roc_solve::module::run_solve_soa(&constraints, constraint, rigid_variables, var_store); roc_solve::module::run_solve(&constraints, constraint, rigid_variables, var_store);
let exposed_vars_by_symbol: Vec<_> = solved_env let exposed_vars_by_symbol: Vec<_> = solved_env
.vars_by_symbol() .vars_by_symbol()
@ -3260,7 +3260,7 @@ fn canonicalize_and_constrain<'a>(
let mut constraints = Constraints::new(); let mut constraints = Constraints::new();
let constraint = let constraint =
constrain_module_soa(&mut constraints, &module_output.declarations, module_id); constrain_module(&mut constraints, &module_output.declarations, module_id);
let module = Module { let module = Module {
module_id, module_id,

View file

@ -16,7 +16,7 @@ pub struct SolvedModule {
pub problems: Vec<solve::TypeError>, pub problems: Vec<solve::TypeError>,
} }
pub fn run_solve_soa( pub fn run_solve(
constraints: &Constraints, constraints: &Constraints,
constraint: ConstraintSoa, constraint: ConstraintSoa,
rigid_variables: MutMap<Variable, Lowercase>, rigid_variables: MutMap<Variable, Lowercase>,