1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-13 11:16:48 +03:00

Add _caseTypeWholeExpression to Internal (#1860)

This commit is contained in:
janmasrovira 2023-02-23 14:50:20 +01:00 committed by GitHub
parent 23f34403f5
commit e0b2d202ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 1 deletions

View File

@ -251,6 +251,7 @@ instance HasExpressions Case where
_caseBranches :: NonEmpty CaseBranch <- traverse (leafExpressions f) (l ^. caseBranches)
_caseExpression <- leafExpressions f (l ^. caseExpression)
_caseExpressionType <- traverse (leafExpressions f) (l ^. caseExpressionType)
_caseExpressionWholeType <- traverse (leafExpressions f) (l ^. caseExpressionWholeType)
pure Case {..}
where
_caseParens = l ^. caseParens

View File

@ -155,8 +155,10 @@ instance Hashable CaseBranch
data Case = Case
{ _caseExpression :: Expression,
-- | The typechecker fills this field
-- | The type of the cased expression. The typechecker fills this field
_caseExpressionType :: Maybe Expression,
-- | The type of the whole case expression. The typechecker fills this field
_caseExpressionWholeType :: Maybe Expression,
_caseBranches :: NonEmpty CaseBranch,
_caseParens :: Bool
}

View File

@ -347,6 +347,7 @@ goCase c = do
_caseBranches <- mapM goCaseBranch (c ^. Abstract.caseBranches)
let _caseParens = c ^. Abstract.caseParens
_caseExpressionType :: Maybe Expression = Nothing
_caseExpressionWholeType :: Maybe Expression = Nothing
return Case {..}
goCaseBranch :: Members '[NameIdGen] r => Abstract.CaseBranch -> Sem r CaseBranch

View File

@ -357,6 +357,7 @@ checkCase ari l = do
_caseExpression <- checkExpression ArityUnit (l ^. caseExpression)
let _caseParens = l ^. caseParens
_caseExpressionType :: Maybe Expression = Nothing
_caseExpressionWholeType :: Maybe Expression = Nothing
return Case {..}
where
checkCaseBranch :: CaseBranch -> Sem r CaseBranch

View File

@ -556,6 +556,7 @@ inferExpression' hint e = case e of
typedCaseExpression <- inferExpression' Nothing (c ^. caseExpression)
let _caseExpression = typedCaseExpression ^. typedExpression
_caseExpressionType = Just (typedCaseExpression ^. typedType)
_caseExpressionWholeType = Just ty
goBranch :: CaseBranch -> Sem r CaseBranch
goBranch b =
traverseOf