Skip to content

Commit

Permalink
use void
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Feb 6, 2024
1 parent 2627067 commit 4d7978e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Juvix/Compiler/Tree/Transformation/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ inferType tab funInfo = goInfer mempty
checkBinop ty1' ty2' rty = do
ty1 <- goInfer bl _nodeBinopArg1
ty2 <- goInfer bl _nodeBinopArg2
_ <- unifyTypes' loc tab ty1 ty1'
_ <- unifyTypes' loc tab ty2 ty2'
void $ unifyTypes' loc tab ty1 ty1'
void $ unifyTypes' loc tab ty2 ty2'
return rty

goUnop :: BinderList Type -> NodeUnop -> Sem r Type
Expand All @@ -63,7 +63,7 @@ inferType tab funInfo = goInfer mempty
checkUnop :: Type -> Type -> Sem r Type
checkUnop ty rty = do
ty' <- goInfer bl _nodeUnopArg
_ <- unifyTypes' loc tab ty ty'
void $ unifyTypes' loc tab ty ty'
return rty

goConst :: BinderList Type -> NodeConstant -> Sem r Type
Expand Down Expand Up @@ -253,14 +253,13 @@ inferType tab funInfo = goInfer mempty
checkType :: BinderList Type -> Node -> Type -> Sem r ()
checkType bl node ty = do
ty' <- goInfer bl node
_ <- unifyTypes' (getNodeLocation node) tab ty ty'
return ()
void $ unifyTypes' (getNodeLocation node) tab ty ty'

validateFunction :: (Member (Error TreeError) r) => InfoTable -> FunctionInfo -> Sem r FunctionInfo
validateFunction tab funInfo = do
ty <- inferType tab funInfo (funInfo ^. functionCode)
let ty' = if funInfo ^. functionArgsNum == 0 then funInfo ^. functionType else typeTarget (funInfo ^. functionType)
_ <- unifyTypes' (funInfo ^. functionLocation) tab ty ty'
void $ unifyTypes' (funInfo ^. functionLocation) tab ty ty'
return funInfo

validate :: (Member (Error TreeError) r) => InfoTable -> Sem r InfoTable
Expand Down

0 comments on commit 4d7978e

Please sign in to comment.