typeExpr (Op2Expr p e1 BiDivide e2) = unify IntType e1 >>| unify IntType e2
typeExpr (Op2Expr p e1 BiMod e2) = unify IntType e1 >>| unify IntType e2
//bool, char of int
-typeExpr (Op2Expr p e1 BiEquals e2) = undef
-typeExpr (Op2Expr p e1 BiUnEqual e2) = undef
+typeExpr (Op2Expr p e1 BiEquals e2) = typeExpr e1 >>= \t1 -> unify t1 e2
+ >>| pure BoolType //todo, actually check t1 in Char,Bool,Int
+typeExpr (Op2Expr p e1 BiUnEqual e2) = typeExpr (Op2Expr p e1 BiEquals e2)
//char of int
-typeExpr (Op2Expr p e1 BiLesser e2) = undef
-typeExpr (Op2Expr p e1 BiGreater e2) = undef
-typeExpr (Op2Expr p e1 BiLesserEq e2) = undef
-typeExpr (Op2Expr p e1 BiGreaterEq e2) = undef
+typeExpr (Op2Expr p e1 BiLesser e2) = typeExpr e1 >>= \t1 -> unify t1 e2
+ >>| pure BoolType //todo, actually check t1 in Char, Int
+typeExpr (Op2Expr p e1 BiGreater e2) = typeExpr (Op2Expr p e1 BiLesser e2)
+typeExpr (Op2Expr p e1 BiLesserEq e2) = typeExpr (Op2Expr p e1 BiLesser e2)
+typeExpr (Op2Expr p e1 BiGreaterEq e2) = typeExpr (Op2Expr p e1 BiLesser e2)
//bool
-typeExpr (Op2Expr p e1 BiAnd e2) = undef
-typeExpr (Op2Expr p e1 BiOr e2) = undef
+typeExpr (Op2Expr p e1 BiAnd e2) = unify BoolType e1 >>| unify BoolType e2
+typeExpr (Op2Expr p e1 BiOr e2) = unify BoolType e1 >>| unify BoolType e2
//a
-typeExpr (Op2Expr p e1 BiCons e2) = undef
-//typeExpr (FunExpr Pos FunCall) = undef
-//typeExpr (EmptyListExpr Pos) = undef
+typeExpr (Op2Expr p e1 BiCons e2) = typeExpr e1 >>= \t1-> typeExpr e2
+ >>= \t2-> unify (ListType t1) t2
+//typeExpr (FunExpr p FunCall) = undef
+typeExpr (EmptyListExpr p) = pure $ ListType IntType //we'll need quantified types
//typeExpr (VarExpr Pos VarDef) = undef //when checking var-expr, be sure to
-//put the infered type
- //in the context
+ //put the infered type in the context
class unify a :: Type a -> Env Type
unify IntType IntType = pure IntType
unify BoolType BoolType = pure BoolType
unify CharType CharType = pure CharType
+ unify (ListType t1) (ListType t2) = unify t1 t2
unify t1 t2 = liftT $ Left $ UnifyError zero t1 t2
instance zero Pos where
extrPos (BoolExpr p _) = p
extrPos (FunExpr p _) = p
extrPos (EmptyListExpr p) = p
-extrPos (TupleExpr p _) = p
+extrPos (TupleExpr p _) = p
\ No newline at end of file