mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
Add type annotation to case expression (#1849)
This commit is contained in:
parent
dd8457d097
commit
ca4926527e
@ -250,6 +250,7 @@ instance HasExpressions Case where
|
||||
leafExpressions f l = do
|
||||
_caseBranches :: NonEmpty CaseBranch <- traverse (leafExpressions f) (l ^. caseBranches)
|
||||
_caseExpression <- leafExpressions f (l ^. caseExpression)
|
||||
_caseExpressionType <- traverse (leafExpressions f) (l ^. caseExpressionType)
|
||||
pure Case {..}
|
||||
where
|
||||
_caseParens = l ^. caseParens
|
||||
|
@ -155,6 +155,8 @@ instance Hashable CaseBranch
|
||||
|
||||
data Case = Case
|
||||
{ _caseExpression :: Expression,
|
||||
-- | The typechecker fills this field
|
||||
_caseExpressionType :: Maybe Expression,
|
||||
_caseBranches :: NonEmpty CaseBranch,
|
||||
_caseParens :: Bool
|
||||
}
|
||||
|
@ -346,6 +346,7 @@ goCase c = do
|
||||
_caseExpression <- goExpression (c ^. Abstract.caseExpression)
|
||||
_caseBranches <- mapM goCaseBranch (c ^. Abstract.caseBranches)
|
||||
let _caseParens = c ^. Abstract.caseParens
|
||||
_caseExpressionType :: Maybe Expression = Nothing
|
||||
return Case {..}
|
||||
|
||||
goCaseBranch :: Members '[NameIdGen] r => Abstract.CaseBranch -> Sem r CaseBranch
|
||||
|
@ -356,6 +356,7 @@ checkCase ari l = do
|
||||
_caseBranches <- mapM checkCaseBranch (l ^. caseBranches)
|
||||
_caseExpression <- checkExpression ArityUnit (l ^. caseExpression)
|
||||
let _caseParens = l ^. caseParens
|
||||
_caseExpressionType :: Maybe Expression = Nothing
|
||||
return Case {..}
|
||||
where
|
||||
checkCaseBranch :: CaseBranch -> Sem r CaseBranch
|
||||
|
@ -555,6 +555,7 @@ inferExpression' hint e = case e of
|
||||
Just hi -> return hi
|
||||
typedCaseExpression <- inferExpression' Nothing (c ^. caseExpression)
|
||||
let _caseExpression = typedCaseExpression ^. typedExpression
|
||||
_caseExpressionType = Just (typedCaseExpression ^. typedType)
|
||||
goBranch :: CaseBranch -> Sem r CaseBranch
|
||||
goBranch b =
|
||||
traverseOf
|
||||
|
Loading…
Reference in New Issue
Block a user