Skip to content

Commit

Permalink
add ValueType
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed May 30, 2023
1 parent 121063c commit 0126124
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Juvix/Compiler/Core/Extra/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ toValue tab = \case
NCtr c -> goConstr c
NLam lam -> goLambda lam
Closure {..} -> toValue tab (substEnv _closureEnv _closureNode)
_ -> impossible
NPi {} -> goType
NUniv {} -> goType
NTyp {} -> goType
NPrim {} -> goType
NVar {} -> impossible
NIdt {} -> impossible
NApp {} -> impossible
NBlt {} -> impossible
NLet {} -> impossible
NRec {} -> impossible
NCase {} -> impossible
NMatch {} -> impossible
NDyn {} -> impossible
NBot {} -> impossible
where
goConstr :: Constr -> Value
goConstr Constr {..} =
Expand All @@ -29,6 +42,9 @@ toValue tab = \case
ii = lookupInductiveInfo tab (ci ^. constructorInductive)
paramsNum = length (ii ^. inductiveParams)

goType :: Value
goType = ValueType

goLambda :: Lambda -> Value
goLambda lam =
let (lams, body) = unfoldLambdas (NLam lam)
Expand All @@ -40,5 +56,4 @@ toValue tab = \case
case body of
NCtr c ->
toValue tab (NCtr (over constrArgs (dropEnd n) c))
_ ->
ValueFun
_ -> ValueFun
2 changes: 2 additions & 0 deletions src/Juvix/Compiler/Core/Language/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data Value
| ValueConstant ConstantValue
| ValueWildcard
| ValueFun
| ValueType

makeLenses ''ConstrApp

Expand All @@ -29,3 +30,4 @@ instance HasAtomicity Value where
ValueConstant {} -> Atom
ValueWildcard -> Atom
ValueFun -> Atom
ValueType -> Atom
1 change: 1 addition & 0 deletions src/Juvix/Compiler/Core/Pretty/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ instance PrettyCode Value where
ValueConstant c -> ppCode c
ValueWildcard -> return "_"
ValueFun -> return "<fun>"
ValueType -> return "<type>"

ppValueSequence :: Member (Reader Options) r => [Value] -> Sem r (Doc Ann)
ppValueSequence vs = hsep <$> mapM (ppRightExpression appFixity) vs
Expand Down

0 comments on commit 0126124

Please sign in to comment.