- unify IntType IntType = pure $ Right IntType
- unify BoolType BoolType = pure $ Right BoolType
- unify CharType CharType = pure $ Right CharType
- unify _ _ = undef
-//
-//instance unify Expr where
-// unify type expr = case type of
-// _ ->> _ = Left $ ParseError (extrPos expr)
-// "Expression cannot be a higher order function. Yet..."
-// VoidType = Left $ ParseError (extrPos expr)
-// "Expression cannot be a Void type."
-// IdType _ = Left $ ParseError (extrPos expr)
-// "Expression cannot be an polymorf type."
-// TupleType (_, _) = undef
-// ListType _ = undef
-// IntType = undef
-// BoolType = undef
-// CharType = undef
-// VarType = undef
+ unify IntType IntType = pure IntType
+ unify BoolType BoolType = pure BoolType
+ unify CharType CharType = pure CharType
+ unify t1 t2 = liftT $ Left $ UnifyError zero t1 t2
+
+instance zero Pos where
+ zero = {line=0,col=0}
+
+decErr :: Expr SemError -> SemError
+decErr e (UnifyError _ t1 t2) = UnifyError (extrPos e) t1 t2
+decErr e (ParseError _ s) = ParseError (extrPos e) s
+decErr e err = err
+
+dc2 :: Expr (Either SemError a) -> Either SemError a
+dc2 e (Right t) = Right t
+dc2 e (Left err) = Left err
+
+extrPos :: Expr -> Pos
+extrPos (VarExpr p _) = p
+extrPos (Op2Expr p _ _ _) = p
+extrPos (Op1Expr p _ _) = p
+extrPos (IntExpr p _) = p
+extrPos (CharExpr p _) = p
+extrPos (BoolExpr p _) = p
+extrPos (FunExpr p _) = p
+extrPos (EmptyListExpr p) = p
+extrPos (TupleExpr p _) = p
\ No newline at end of file