Change name of monad in which type inference happens
This commit is contained in:
parent
fab3fb8ec2
commit
65c47c20fc
@ -8,7 +8,7 @@ pub struct TypeContext {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypeResult<T> = Result<T, TypeError>;
|
type InferResult<T> = Result<T, TypeError>;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct TypeError { }
|
struct TypeError { }
|
||||||
@ -56,7 +56,7 @@ impl TypeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TypeContext {
|
impl TypeContext {
|
||||||
fn infer_ast(&mut self, ast: &AST) -> TypeResult<MonoType> {
|
fn infer_ast(&mut self, ast: &AST) -> InferResult<MonoType> {
|
||||||
let mut output = MonoType::Const(TConst::Unit);
|
let mut output = MonoType::Const(TConst::Unit);
|
||||||
for statement in ast.0.iter() {
|
for statement in ast.0.iter() {
|
||||||
output = match statement {
|
output = match statement {
|
||||||
@ -67,18 +67,18 @@ impl TypeContext {
|
|||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_expr(&mut self, expr: &Expression) -> TypeResult<MonoType> {
|
fn infer_expr(&mut self, expr: &Expression) -> InferResult<MonoType> {
|
||||||
match expr {
|
match expr {
|
||||||
Expression(expr_type, Some(type_anno)) => unimplemented!(),
|
Expression(expr_type, Some(type_anno)) => unimplemented!(),
|
||||||
Expression(expr_type, None) => self.infer_expr_type(expr_type)
|
Expression(expr_type, None) => self.infer_expr_type(expr_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_decl(&mut self, expr: &Declaration) -> TypeResult<MonoType> {
|
fn infer_decl(&mut self, expr: &Declaration) -> InferResult<MonoType> {
|
||||||
Ok(MonoType::Const(TConst::user("unimplemented")))
|
Ok(MonoType::Const(TConst::user("unimplemented")))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_expr_type(&mut self, expr_type: &ExpressionType) -> TypeResult<MonoType> {
|
fn infer_expr_type(&mut self, expr_type: &ExpressionType) -> InferResult<MonoType> {
|
||||||
use self::ExpressionType::*;
|
use self::ExpressionType::*;
|
||||||
match expr_type {
|
match expr_type {
|
||||||
NatLiteral(_) => Ok(MonoType::Const(TConst::Nat)),
|
NatLiteral(_) => Ok(MonoType::Const(TConst::Nat)),
|
||||||
|
Loading…
Reference in New Issue
Block a user