1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00

Add ValueType (#2143)

- Closes #2136
This commit is contained in:
Jan Mas Rovira 2023-05-30 11:51:28 +02:00 committed by GitHub
parent e944f85074
commit b4154f70a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -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 {..} =
@ -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)
@ -40,5 +56,4 @@ toValue tab = \case
case body of
NCtr c ->
toValue tab (NCtr (over constrArgs (dropEnd n) c))
_ ->
ValueFun
_ -> ValueFun

View File

@ -15,6 +15,7 @@ data Value
| ValueConstant ConstantValue
| ValueWildcard
| ValueFun
| ValueType
makeLenses ''ConstrApp
@ -29,3 +30,4 @@ instance HasAtomicity Value where
ValueConstant {} -> Atom
ValueWildcard -> Atom
ValueFun -> Atom
ValueType -> Atom

View File

@ -597,7 +597,8 @@ instance PrettyCode Value where
ValueConstrApp x -> ppCode x
ValueConstant c -> ppCode c
ValueWildcard -> return "_"
ValueFun -> return "<fun>"
ValueFun -> return "<function>"
ValueType -> return "<type>"
ppValueSequence :: Member (Reader Options) r => [Value] -> Sem r (Doc Ann)
ppValueSequence vs = hsep <$> mapM (ppRightExpression appFixity) vs