Go back to Apply being Vec<Var>

This commit is contained in:
Richard Feldman 2019-08-28 00:55:42 -04:00
parent 7e5d903e9e
commit 2bae47638a
5 changed files with 9 additions and 12 deletions

View file

@ -39,7 +39,7 @@ fn write_flat_type(flat_type: FlatType, subs: &mut Subs, buf: &mut String, use_p
for arg in args { for arg in args {
buf.push_str(" "); buf.push_str(" ");
write_content(arg, subs, buf, true); write_content(subs.get(arg).content, subs, buf, true);
} }
if write_parens { if write_parens {

View file

@ -94,13 +94,9 @@ fn type_to_variable(subs: &mut Subs, typ: Type) -> Variable {
match typ { match typ {
Variable(var) => var, Variable(var) => var,
Apply(module_name, name, arg_types) => { Apply(module_name, name, arg_types) => {
let args: Vec<Content> = let args: Vec<Variable> =
arg_types.into_iter() arg_types.into_iter()
.map(|arg| { .map(|arg| type_to_variable(subs, arg))
let var = type_to_variable(subs, arg);
subs.get(var).content
})
.collect(); .collect();
let flat_type = FlatType::Apply(module_name, name, args); let flat_type = FlatType::Apply(module_name, name, args);

View file

@ -130,7 +130,7 @@ pub enum Content {
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum FlatType { pub enum FlatType {
Apply(String /* module name */, String /* type name */, Vec<Content>), Apply(String /* module name */, String /* type name */, Vec<Variable>),
Func(Variable, Variable), Func(Variable, Variable),
EmptyRecord, EmptyRecord,
} }

View file

@ -55,10 +55,11 @@ fn unify_flat_type(left: &FlatType, right: &FlatType) -> Descriptor {
Apply(l_module_name, l_type_name, l_args), Apply(l_module_name, l_type_name, l_args),
Apply(r_module_name, r_type_name, r_args) Apply(r_module_name, r_type_name, r_args)
) if l_module_name == r_module_name && l_type_name == r_type_name => { ) if l_module_name == r_module_name && l_type_name == r_type_name => {
let args = unify_args(l_args.iter(), r_args.iter()); panic!("TODO fix this by forking ena");
let flat_type = Apply(l_module_name.clone(), l_type_name.clone(), args); // let args = unify_args(l_args.iter(), r_args.iter());
// let flat_type = Apply(l_module_name.clone(), l_type_name.clone(), args);
from_content(Structure(flat_type)) // from_content(Structure(flat_type))
}, },
(Func(_, _), Func(_, _)) => panic!("TODO unify_flat_type for Func"), (Func(_, _), Func(_, _)) => panic!("TODO unify_flat_type for Func"),
_ => from_content(Error) _ => from_content(Error)

View file

@ -59,7 +59,7 @@ mod test_infer {
(loc_expr.value, procedures) (loc_expr.value, procedures)
} }
fn apply(module_name: &str, type_name: &str, args: Vec<Content>) -> Content { fn apply(module_name: &str, type_name: &str, args: Vec<Variable>) -> Content {
Structure(FlatType::Apply(module_name.to_string(), type_name.to_string(), args)) Structure(FlatType::Apply(module_name.to_string(), type_name.to_string(), args))
} }