mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
Move unify::Mode to roc_solve_schema
This commit is contained in:
parent
87d108eccc
commit
18e9f8f034
19 changed files with 140 additions and 98 deletions
|
|
@ -21,6 +21,7 @@ roc_packaging = { path = "../../packaging" }
|
|||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_solve_problem = { path = "../solve_problem" }
|
||||
roc_solve_schema = { path = "../solve_schema" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use roc_solve_problem::{
|
|||
NotDerivableContext, NotDerivableDecode, NotDerivableEncode, NotDerivableEq, TypeError,
|
||||
UnderivableReason, Unfulfilled,
|
||||
};
|
||||
use roc_solve_schema::UnificationMode;
|
||||
use roc_types::num::NumericRange;
|
||||
use roc_types::subs::{
|
||||
instantiate_rigids, Content, FlatType, GetSubsSlice, Rank, RecordFields, Subs, SubsSlice,
|
||||
|
|
@ -1287,7 +1288,7 @@ impl DerivableVisitor for DeriveEq {
|
|||
subs: &mut Subs,
|
||||
content_var: Variable,
|
||||
) -> Result<Descend, NotDerivable> {
|
||||
use roc_unify::unify::{unify, Mode};
|
||||
use roc_unify::unify::unify;
|
||||
|
||||
// Of the floating-point types,
|
||||
// only Dec implements Eq.
|
||||
|
|
@ -1299,7 +1300,7 @@ impl DerivableVisitor for DeriveEq {
|
|||
}),
|
||||
content_var,
|
||||
Variable::DECIMAL,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::Pos,
|
||||
);
|
||||
match unified {
|
||||
|
|
@ -1417,7 +1418,7 @@ pub fn resolve_ability_specialization<R: AbilityResolver>(
|
|||
ability_member: Symbol,
|
||||
specialization_var: Variable,
|
||||
) -> Result<Resolved, ResolveError> {
|
||||
use roc_unify::unify::{unify, Mode};
|
||||
use roc_unify::unify::unify;
|
||||
|
||||
let (parent_ability, signature_var) = resolver
|
||||
.member_parent_and_signature_var(ability_member, subs)
|
||||
|
|
@ -1435,7 +1436,7 @@ pub fn resolve_ability_specialization<R: AbilityResolver>(
|
|||
}),
|
||||
specialization_var,
|
||||
signature_var,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::Pos,
|
||||
)
|
||||
.expect_success(
|
||||
|
|
|
|||
|
|
@ -24,13 +24,14 @@ use roc_module::symbol::Symbol;
|
|||
use roc_problem::can::CycleEntry;
|
||||
use roc_region::all::Loc;
|
||||
use roc_solve_problem::TypeError;
|
||||
use roc_solve_schema::UnificationMode;
|
||||
use roc_types::subs::{
|
||||
self, Content, FlatType, GetSubsSlice, Mark, OptVariable, Rank, Subs, TagExt, UlsOfVar,
|
||||
Variable,
|
||||
};
|
||||
use roc_types::types::{Category, Polarity, Reason, RecordField, Type, TypeExtension, Types, Uls};
|
||||
use roc_unify::unify::{
|
||||
unify, unify_introduced_ability_specialization, Mode, Obligated, SpecializationLsetCollector,
|
||||
unify, unify_introduced_ability_specialization, Obligated, SpecializationLsetCollector,
|
||||
Unified::*,
|
||||
};
|
||||
|
||||
|
|
@ -489,7 +490,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
actual,
|
||||
expected,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
Success {
|
||||
|
|
@ -600,7 +601,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
actual,
|
||||
expected,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
Success {
|
||||
|
|
@ -699,8 +700,8 @@ fn solve(
|
|||
);
|
||||
|
||||
let mode = match constraint {
|
||||
PatternPresence(..) => Mode::PRESENT,
|
||||
_ => Mode::EQ,
|
||||
PatternPresence(..) => UnificationMode::PRESENT,
|
||||
_ => UnificationMode::EQ,
|
||||
};
|
||||
|
||||
match unify(
|
||||
|
|
@ -919,7 +920,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
actual,
|
||||
includes,
|
||||
Mode::PRESENT,
|
||||
UnificationMode::PRESENT,
|
||||
Polarity::OF_PATTERN,
|
||||
) {
|
||||
Success {
|
||||
|
|
@ -1053,7 +1054,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
branches_var,
|
||||
real_var,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
cond_polarity,
|
||||
);
|
||||
|
||||
|
|
@ -1103,7 +1104,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
real_var,
|
||||
branches_var,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
cond_polarity,
|
||||
),
|
||||
Success { .. }
|
||||
|
|
@ -1121,7 +1122,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
real_var,
|
||||
branches_var,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
cond_polarity,
|
||||
) {
|
||||
Failure(vars, actual_type, expected_type, _bad_impls) => {
|
||||
|
|
@ -1320,7 +1321,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
actual,
|
||||
Variable::LIST_U8,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
// List U8 always valid.
|
||||
|
|
@ -1340,7 +1341,7 @@ fn solve(
|
|||
&mut env.uenv(),
|
||||
actual,
|
||||
Variable::STR,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
Success {
|
||||
|
|
@ -1591,7 +1592,7 @@ fn check_ability_specialization(
|
|||
&mut env.uenv(),
|
||||
root_signature_var,
|
||||
symbol_loc_var.value,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
);
|
||||
|
||||
let resolved_mark = match unified {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use roc_debug_flags::ROC_TRACE_COMPACTION;
|
|||
use roc_derive_key::{DeriveError, DeriveKey};
|
||||
use roc_error_macros::{internal_error, todo_abilities};
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
use roc_solve_schema::UnificationMode;
|
||||
use roc_types::{
|
||||
subs::{
|
||||
get_member_lambda_sets_at_region, Content, Descriptor, GetSubsSlice, LambdaSet, Mark,
|
||||
|
|
@ -17,7 +18,7 @@ use roc_types::{
|
|||
},
|
||||
types::{AliasKind, MemberImpl, Polarity, Uls},
|
||||
};
|
||||
use roc_unify::unify::{unify, Mode, MustImplementConstraints};
|
||||
use roc_unify::unify::{unify, MustImplementConstraints};
|
||||
|
||||
use crate::{
|
||||
ability::builtin_module_with_unlisted_ability_impl,
|
||||
|
|
@ -577,7 +578,7 @@ fn compact_lambda_set<P: Phase>(
|
|||
&mut env.uenv(),
|
||||
t_f1,
|
||||
t_f2,
|
||||
Mode::LAMBDA_SET_SPECIALIZATION,
|
||||
UnificationMode::LAMBDA_SET_SPECIALIZATION,
|
||||
Polarity::Pos,
|
||||
)
|
||||
.expect_success("ambient functions don't unify");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use roc_error_macros::internal_error;
|
|||
use roc_module::{ident::TagName, symbol::Symbol};
|
||||
use roc_region::all::Loc;
|
||||
use roc_solve_problem::TypeError;
|
||||
use roc_solve_schema::UnificationMode;
|
||||
use roc_types::{
|
||||
subs::{
|
||||
self, AliasVariables, Content, FlatType, GetSubsSlice, LambdaSet, OptVariable, Rank,
|
||||
|
|
@ -17,7 +18,7 @@ use roc_types::{
|
|||
Category, ExtImplicitOpenness, Polarity, TypeTag, Types,
|
||||
},
|
||||
};
|
||||
use roc_unify::unify::{unify, Mode, Unified};
|
||||
use roc_unify::unify::{unify, Unified};
|
||||
|
||||
use crate::{
|
||||
ability::{AbilityImplError, ObligationCache},
|
||||
|
|
@ -875,7 +876,7 @@ pub(crate) fn type_to_var_help(
|
|||
&mut env.uenv(),
|
||||
var,
|
||||
flex_ability,
|
||||
Mode::EQ,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
Unified::Success {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue