mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-08-16 15:11:06 +03:00
Merge pull request #86 from VitorCBSB/master
Chapter 5: Fixed Type Mismatch message for If.
This commit is contained in:
commit
5c515bd386
@ -404,7 +404,7 @@ typeof expr = case expr of
|
|||||||
then throwError $ TypeMismatch ta TBool
|
then throwError $ TypeMismatch ta TBool
|
||||||
else
|
else
|
||||||
if tb /= tc
|
if tb /= tc
|
||||||
then throwError $ TypeMismatch ta tb
|
then throwError $ TypeMismatch tb tc
|
||||||
else return tc
|
else return tc
|
||||||
|
|
||||||
Tr -> return TBool
|
Tr -> return TBool
|
||||||
@ -484,7 +484,7 @@ We can consider a very simple type system for our language that will consist of
|
|||||||
$$
|
$$
|
||||||
\begin{aligned}
|
\begin{aligned}
|
||||||
\tau :=\ & \t{Int} \\
|
\tau :=\ & \t{Int} \\
|
||||||
& \t{Bool} \\
|
& \t{Bool} \\
|
||||||
& \tau \rightarrow \tau \\
|
& \tau \rightarrow \tau \\
|
||||||
\end{aligned}
|
\end{aligned}
|
||||||
$$
|
$$
|
||||||
|
@ -48,7 +48,7 @@ typeof expr = case expr of
|
|||||||
then throwError $ TypeMismatch ta TBool
|
then throwError $ TypeMismatch ta TBool
|
||||||
else
|
else
|
||||||
if tb /= tc
|
if tb /= tc
|
||||||
then throwError $ TypeMismatch ta tb
|
then throwError $ TypeMismatch tb tc
|
||||||
else return tc
|
else return tc
|
||||||
|
|
||||||
check :: Expr -> Either TypeError Type
|
check :: Expr -> Either TypeError Type
|
||||||
|
Loading…
Reference in New Issue
Block a user