mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46: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
|
leafExpressions f l = do
|
||||||
_caseBranches :: NonEmpty CaseBranch <- traverse (leafExpressions f) (l ^. caseBranches)
|
_caseBranches :: NonEmpty CaseBranch <- traverse (leafExpressions f) (l ^. caseBranches)
|
||||||
_caseExpression <- leafExpressions f (l ^. caseExpression)
|
_caseExpression <- leafExpressions f (l ^. caseExpression)
|
||||||
|
_caseExpressionType <- traverse (leafExpressions f) (l ^. caseExpressionType)
|
||||||
pure Case {..}
|
pure Case {..}
|
||||||
where
|
where
|
||||||
_caseParens = l ^. caseParens
|
_caseParens = l ^. caseParens
|
||||||
|
@ -155,6 +155,8 @@ instance Hashable CaseBranch
|
|||||||
|
|
||||||
data Case = Case
|
data Case = Case
|
||||||
{ _caseExpression :: Expression,
|
{ _caseExpression :: Expression,
|
||||||
|
-- | The typechecker fills this field
|
||||||
|
_caseExpressionType :: Maybe Expression,
|
||||||
_caseBranches :: NonEmpty CaseBranch,
|
_caseBranches :: NonEmpty CaseBranch,
|
||||||
_caseParens :: Bool
|
_caseParens :: Bool
|
||||||
}
|
}
|
||||||
|
@ -346,6 +346,7 @@ goCase c = do
|
|||||||
_caseExpression <- goExpression (c ^. Abstract.caseExpression)
|
_caseExpression <- goExpression (c ^. Abstract.caseExpression)
|
||||||
_caseBranches <- mapM goCaseBranch (c ^. Abstract.caseBranches)
|
_caseBranches <- mapM goCaseBranch (c ^. Abstract.caseBranches)
|
||||||
let _caseParens = c ^. Abstract.caseParens
|
let _caseParens = c ^. Abstract.caseParens
|
||||||
|
_caseExpressionType :: Maybe Expression = Nothing
|
||||||
return Case {..}
|
return Case {..}
|
||||||
|
|
||||||
goCaseBranch :: Members '[NameIdGen] r => Abstract.CaseBranch -> Sem r CaseBranch
|
goCaseBranch :: Members '[NameIdGen] r => Abstract.CaseBranch -> Sem r CaseBranch
|
||||||
|
@ -356,6 +356,7 @@ checkCase ari l = do
|
|||||||
_caseBranches <- mapM checkCaseBranch (l ^. caseBranches)
|
_caseBranches <- mapM checkCaseBranch (l ^. caseBranches)
|
||||||
_caseExpression <- checkExpression ArityUnit (l ^. caseExpression)
|
_caseExpression <- checkExpression ArityUnit (l ^. caseExpression)
|
||||||
let _caseParens = l ^. caseParens
|
let _caseParens = l ^. caseParens
|
||||||
|
_caseExpressionType :: Maybe Expression = Nothing
|
||||||
return Case {..}
|
return Case {..}
|
||||||
where
|
where
|
||||||
checkCaseBranch :: CaseBranch -> Sem r CaseBranch
|
checkCaseBranch :: CaseBranch -> Sem r CaseBranch
|
||||||
|
@ -555,6 +555,7 @@ inferExpression' hint e = case e of
|
|||||||
Just hi -> return hi
|
Just hi -> return hi
|
||||||
typedCaseExpression <- inferExpression' Nothing (c ^. caseExpression)
|
typedCaseExpression <- inferExpression' Nothing (c ^. caseExpression)
|
||||||
let _caseExpression = typedCaseExpression ^. typedExpression
|
let _caseExpression = typedCaseExpression ^. typedExpression
|
||||||
|
_caseExpressionType = Just (typedCaseExpression ^. typedType)
|
||||||
goBranch :: CaseBranch -> Sem r CaseBranch
|
goBranch :: CaseBranch -> Sem r CaseBranch
|
||||||
goBranch b =
|
goBranch b =
|
||||||
traverseOf
|
traverseOf
|
||||||
|
Loading…
Reference in New Issue
Block a user