Remove Blank, support Erroneous

This commit is contained in:
Richard Feldman 2019-08-29 23:54:10 -04:00
parent ded3ba7f54
commit 10631d0dd0
4 changed files with 10 additions and 11 deletions

View file

@ -70,6 +70,9 @@ fn write_flat_type(flat_type: FlatType, subs: &mut Subs, buf: &mut String, use_p
if use_parens { if use_parens {
buf.push_str(")"); buf.push_str(")");
} }
},
Erroneous(problem) => {
buf.push_str(&format!("<Type Mismatch: {:?}>", problem));
} }
} }
} }

View file

@ -106,16 +106,11 @@ fn type_to_variable(subs: &mut Subs, typ: Type) -> Variable {
subs.fresh(Descriptor::from(content)) subs.fresh(Descriptor::from(content))
}, },
_ => panic!("TODO type_to_var {:?}", typ) Erroneous(problem) => {
let content = Content::Structure(FlatType::Erroneous(problem));
// AppN home name args -> subs.fresh(Descriptor::from(content))
// do argVars <- traverse go args }
// register rank pools (Structure (App1 home name argVars))
// FunN a b ->
// do aVar <- go a
// bVar <- go b
// register rank pools (Structure (Fun1 aVar bVar))
} }
} }

View file

@ -1,7 +1,9 @@
use ena::unify::{UnificationTable, UnifyKey, InPlace}; use ena::unify::{UnificationTable, UnifyKey, InPlace};
use std::fmt; use std::fmt;
use types::Problem;
use unify; use unify;
#[derive(Debug)]
pub struct Subs { pub struct Subs {
utable: UnificationTable<InPlace<Variable>> utable: UnificationTable<InPlace<Variable>>
} }
@ -141,6 +143,7 @@ pub enum Content {
pub enum FlatType { pub enum FlatType {
Apply(String /* module name */, String /* type name */, Vec<Variable>), Apply(String /* module name */, String /* type name */, Vec<Variable>),
Func(Vec<Variable>, Variable), Func(Vec<Variable>, Variable),
Erroneous(Problem),
EmptyRecord, EmptyRecord,
} }

View file

@ -15,8 +15,6 @@ pub enum Type {
/// Applying a type to some arguments (e.g. Map.Map String Int) /// Applying a type to some arguments (e.g. Map.Map String Int)
Apply(ModuleName, String, Vec<Type>), Apply(ModuleName, String, Vec<Type>),
Variable(Variable), Variable(Variable),
/// A Blank in the editor (a "typed hole" as they're also known)
Blank,
/// A type error, which will code gen to a runtime error /// A type error, which will code gen to a runtime error
Erroneous(Problem), Erroneous(Problem),
} }