mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Basic type inference and solving for abilities
Note that is still pretty limited. We only permit opaque types to implement abilities, abilities cannot have type arguments, and also no other functions may depend on abilities
This commit is contained in:
parent
913d97cab1
commit
15a040ec87
25 changed files with 1808 additions and 477 deletions
|
@ -1,4 +1,5 @@
|
|||
use roc_builtins::std::StdLib;
|
||||
use roc_can::abilities::AbilitiesStore;
|
||||
use roc_can::constraint::{Constraint, Constraints};
|
||||
use roc_can::def::Declaration;
|
||||
use roc_collections::all::MutMap;
|
||||
|
@ -100,10 +101,26 @@ pub enum ExposedModuleTypes {
|
|||
|
||||
pub fn constrain_module(
|
||||
constraints: &mut Constraints,
|
||||
abilities_store: &AbilitiesStore,
|
||||
declarations: &[Declaration],
|
||||
home: ModuleId,
|
||||
) -> Constraint {
|
||||
crate::expr::constrain_decls(constraints, home, declarations)
|
||||
let mut constraint = crate::expr::constrain_decls(constraints, home, declarations);
|
||||
|
||||
for (member_name, member_data) in abilities_store.root_ability_members().iter() {
|
||||
constraint = constraints.let_constraint(
|
||||
[],
|
||||
[],
|
||||
[(*member_name, Loc::at_zero(member_data.signature.clone()))],
|
||||
Constraint::True,
|
||||
constraint,
|
||||
);
|
||||
}
|
||||
|
||||
// The module constraint should always save the environment at the end.
|
||||
debug_assert!(constraints.contains_save_the_environment(&constraint));
|
||||
|
||||
constraint
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue