mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-11-28 05:32:03 +03:00
Count argument position in parameter blocks
We need to know where we are so that we know if we're at an erasable/detaggable argument position
This commit is contained in:
parent
8227859760
commit
e5c70195da
@ -221,7 +221,7 @@ readTTCFile modns as b
|
|||||||
-- coreLift $ putStrLn $ "Read " ++ show (length guesses) ++ " guesses"
|
-- coreLift $ putStrLn $ "Read " ++ show (length guesses) ++ " guesses"
|
||||||
-- constraints <- the (Core (List (Int, Constraint))) $ fromBuf b
|
-- constraints <- the (Core (List (Int, Constraint))) $ fromBuf b
|
||||||
-- coreLift $ putStrLn $ "Read " ++ show (length constraints) ++ " constraints"
|
-- coreLift $ putStrLn $ "Read " ++ show (length constraints) ++ " constraints"
|
||||||
defs <- logTime "Definitions" $ fromBuf b
|
defs <- logTime ("Definitions " ++ show modns) $ fromBuf b
|
||||||
uholes <- fromBuf b
|
uholes <- fromBuf b
|
||||||
autohs <- fromBuf b
|
autohs <- fromBuf b
|
||||||
typehs <- fromBuf b
|
typehs <- fromBuf b
|
||||||
|
@ -17,6 +17,12 @@ length : Env tm xs -> Nat
|
|||||||
length [] = 0
|
length [] = 0
|
||||||
length (_ :: xs) = S (length xs)
|
length (_ :: xs) = S (length xs)
|
||||||
|
|
||||||
|
export
|
||||||
|
lengthNoLet : Env tm xs -> Nat
|
||||||
|
lengthNoLet [] = 0
|
||||||
|
lengthNoLet (Let _ _ _ :: xs) = lengthNoLet xs
|
||||||
|
lengthNoLet (_ :: xs) = S (lengthNoLet xs)
|
||||||
|
|
||||||
public export
|
public export
|
||||||
data IsDefined : Name -> List Name -> Type where
|
data IsDefined : Name -> List Name -> Type where
|
||||||
MkIsDefined : {idx : Nat} -> RigCount -> .(IsVar n idx vars) ->
|
MkIsDefined : {idx : Nat} -> RigCount -> .(IsVar n idx vars) ->
|
||||||
|
@ -77,11 +77,12 @@ getVarType : {vars : _} ->
|
|||||||
{auto e : Ref EST (EState vars)} ->
|
{auto e : Ref EST (EState vars)} ->
|
||||||
RigCount -> NestedNames vars -> Env Term vars ->
|
RigCount -> NestedNames vars -> Env Term vars ->
|
||||||
FC -> Name ->
|
FC -> Name ->
|
||||||
Core (Term vars, Glued vars)
|
Core (Term vars, Nat, Glued vars)
|
||||||
getVarType rigc nest env fc x
|
getVarType rigc nest env fc x
|
||||||
= case lookup x (names nest) of
|
= case lookup x (names nest) of
|
||||||
Nothing => getNameType rigc env fc x
|
Nothing => do (tm, ty) <- getNameType rigc env fc x
|
||||||
Just (nestn, tmf) =>
|
pure (tm, 0, ty)
|
||||||
|
Just (nestn, arglen, tmf) =>
|
||||||
do defs <- get Ctxt
|
do defs <- get Ctxt
|
||||||
let n' = maybe x id nestn
|
let n' = maybe x id nestn
|
||||||
case !(lookupCtxtExact n' (gamma defs)) of
|
case !(lookupCtxtExact n' (gamma defs)) of
|
||||||
@ -98,7 +99,7 @@ getVarType rigc nest env fc x
|
|||||||
do checkVisibleNS fc (fullname ndef) (visibility ndef)
|
do checkVisibleNS fc (fullname ndef) (visibility ndef)
|
||||||
logTerm 10 ("Type of " ++ show n') tyenv
|
logTerm 10 ("Type of " ++ show n') tyenv
|
||||||
logTerm 10 ("Expands to") tm
|
logTerm 10 ("Expands to") tm
|
||||||
pure (tm, gnf env tyenv)
|
pure (tm, arglen, gnf env tyenv)
|
||||||
where
|
where
|
||||||
useVars : List (Term vars) -> Term vars -> Term vars
|
useVars : List (Term vars) -> Term vars -> Term vars
|
||||||
useVars [] sc = sc
|
useVars [] sc = sc
|
||||||
@ -524,7 +525,7 @@ checkApp rig elabinfo nest env fc (IApp fc' fn arg) expargs impargs exp
|
|||||||
checkApp rig elabinfo nest env fc (IImplicitApp fc' fn nm arg) expargs impargs exp
|
checkApp rig elabinfo nest env fc (IImplicitApp fc' fn nm arg) expargs impargs exp
|
||||||
= checkApp rig elabinfo nest env fc' fn expargs ((nm, arg) :: impargs) exp
|
= checkApp rig elabinfo nest env fc' fn expargs ((nm, arg) :: impargs) exp
|
||||||
checkApp rig elabinfo nest env fc (IVar fc' n) expargs impargs exp
|
checkApp rig elabinfo nest env fc (IVar fc' n) expargs impargs exp
|
||||||
= do (ntm, nty_in) <- getVarType rig nest env fc n
|
= do (ntm, arglen, nty_in) <- getVarType rig nest env fc n
|
||||||
nty <- getNF nty_in
|
nty <- getNF nty_in
|
||||||
elabinfo <- updateElabInfo (elabMode elabinfo) n expargs elabinfo
|
elabinfo <- updateElabInfo (elabMode elabinfo) n expargs elabinfo
|
||||||
logC 10 (do defs <- get Ctxt
|
logC 10 (do defs <- get Ctxt
|
||||||
@ -539,7 +540,7 @@ checkApp rig elabinfo nest env fc (IVar fc' n) expargs impargs exp
|
|||||||
" to " ++ show expargs ++ "\n\tFunction type " ++
|
" to " ++ show expargs ++ "\n\tFunction type " ++
|
||||||
(show !(toFullNames fnty)) ++ "\n\tExpected app type "
|
(show !(toFullNames fnty)) ++ "\n\tExpected app type "
|
||||||
++ show exptyt))
|
++ show exptyt))
|
||||||
checkAppWith rig elabinfo nest env fc ntm nty (Just n, 0) expargs impargs False exp
|
checkAppWith rig elabinfo nest env fc ntm nty (Just n, arglen) expargs impargs False exp
|
||||||
where
|
where
|
||||||
isPrimName : List Name -> Name -> Bool
|
isPrimName : List Name -> Name -> Bool
|
||||||
isPrimName [] fn = False
|
isPrimName [] fn = False
|
||||||
|
@ -317,7 +317,7 @@ caseBlock {vars} rigc elabinfo fc nest env scr scrtm scrty caseRig alts expected
|
|||||||
|
|
||||||
let alts' = map (updateClause casen splitOn env smaller) alts
|
let alts' = map (updateClause casen splitOn env smaller) alts
|
||||||
log 2 $ "Generated alts: " ++ show alts'
|
log 2 $ "Generated alts: " ++ show alts'
|
||||||
let nest' = record { names $= ((Resolved cidx, (Nothing,
|
let nest' = record { names $= ((Resolved cidx, (Nothing, length pre_env,
|
||||||
(\fc, nt => applyToFull fc caseRef pre_env))) ::) }
|
(\fc, nt => applyToFull fc caseRef pre_env))) ::) }
|
||||||
nest
|
nest
|
||||||
processDecl [InCase] nest' pre_env (IDef fc casen alts')
|
processDecl [InCase] nest' pre_env (IDef fc casen alts')
|
||||||
|
@ -49,11 +49,11 @@ checkLocal {vars} rig elabinfo nest env fc nestdecls scope expty
|
|||||||
else b :: dropLinear bs
|
else b :: dropLinear bs
|
||||||
|
|
||||||
applyEnv : {auto c : Ref Ctxt Defs} -> Int -> Name ->
|
applyEnv : {auto c : Ref Ctxt Defs} -> Int -> Name ->
|
||||||
Core (Name, (Maybe Name, FC -> NameType -> Term vars))
|
Core (Name, (Maybe Name, Nat, FC -> NameType -> Term vars))
|
||||||
applyEnv outer inner
|
applyEnv outer inner
|
||||||
= do let nestedName = Nested outer inner
|
= do let nestedName = Nested outer inner
|
||||||
n' <- addName nestedName
|
n' <- addName nestedName
|
||||||
pure (inner, (Just nestedName,
|
pure (inner, (Just nestedName, lengthNoLet env,
|
||||||
\fc, nt => applyTo fc
|
\fc, nt => applyTo fc
|
||||||
(Ref fc nt (Resolved n')) env))
|
(Ref fc nt (Resolved n')) env))
|
||||||
|
|
||||||
|
@ -309,10 +309,10 @@ hasEmptyPat defs env _ = pure False
|
|||||||
-- For checking with blocks as nested names
|
-- For checking with blocks as nested names
|
||||||
applyEnv : {auto c : Ref Ctxt Defs} ->
|
applyEnv : {auto c : Ref Ctxt Defs} ->
|
||||||
Env Term vars -> Name ->
|
Env Term vars -> Name ->
|
||||||
Core (Name, (Maybe Name, FC -> NameType -> Term vars))
|
Core (Name, (Maybe Name, Nat, FC -> NameType -> Term vars))
|
||||||
applyEnv env withname
|
applyEnv env withname
|
||||||
= do n' <- resolveName withname
|
= do n' <- resolveName withname
|
||||||
pure (withname, (Just withname,
|
pure (withname, (Just withname, lengthNoLet env,
|
||||||
\fc, nt => applyTo fc
|
\fc, nt => applyTo fc
|
||||||
(Ref fc nt (Resolved n')) env))
|
(Ref fc nt (Resolved n')) env))
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ processParams {vars} {c} {m} {u} nest env fc ps ds
|
|||||||
= IPi fc RigW Explicit (Just n) ty (mkParamTy ps)
|
= IPi fc RigW Explicit (Just n) ty (mkParamTy ps)
|
||||||
|
|
||||||
applyEnv : Env Term vs -> Name ->
|
applyEnv : Env Term vs -> Name ->
|
||||||
Core (Name, (Maybe Name, FC -> NameType -> Term vs))
|
Core (Name, (Maybe Name, Nat, FC -> NameType -> Term vs))
|
||||||
applyEnv env n
|
applyEnv env n
|
||||||
= do n' <- resolveName n -- it'll be Resolved by expandAmbigName
|
= do n' <- resolveName n -- it'll be Resolved by expandAmbigName
|
||||||
pure (Resolved n', (Nothing,
|
pure (Resolved n', (Nothing, lengthNoLet env,
|
||||||
\fc, nt => applyTo fc
|
\fc, nt => applyTo fc
|
||||||
(Ref fc nt (Resolved n')) env))
|
(Ref fc nt (Resolved n')) env))
|
||||||
|
@ -18,15 +18,17 @@ record NestedNames (vars : List Name) where
|
|||||||
-- applied to its enclosing environment
|
-- applied to its enclosing environment
|
||||||
-- Takes the location and name type, because we don't know them until we
|
-- Takes the location and name type, because we don't know them until we
|
||||||
-- elaborate the name at the point of use
|
-- elaborate the name at the point of use
|
||||||
names : List (Name, (Maybe Name, FC -> NameType -> Term vars))
|
names : List (Name, (Maybe Name, -- new name if there is one
|
||||||
|
Nat, -- length of the environment
|
||||||
|
FC -> NameType -> Term vars))
|
||||||
|
|
||||||
export
|
export
|
||||||
Weaken NestedNames where
|
Weaken NestedNames where
|
||||||
weaken (MkNested ns) = MkNested (map wknName ns)
|
weaken (MkNested ns) = MkNested (map wknName ns)
|
||||||
where
|
where
|
||||||
wknName : (Name, (Maybe Name, FC -> NameType -> Term vars)) ->
|
wknName : (Name, (Maybe Name, Nat, FC -> NameType -> Term vars)) ->
|
||||||
(Name, (Maybe Name, FC -> NameType -> Term (n :: vars)))
|
(Name, (Maybe Name, Nat, FC -> NameType -> Term (n :: vars)))
|
||||||
wknName (n, (mn, rep)) = (n, (mn, \fc, nt => weaken (rep fc nt)))
|
wknName (n, (mn, len, rep)) = (n, (mn, len, \fc, nt => weaken (rep fc nt)))
|
||||||
|
|
||||||
-- Unchecked terms, with implicit arguments
|
-- Unchecked terms, with implicit arguments
|
||||||
-- This is the raw, elaboratable form.
|
-- This is the raw, elaboratable form.
|
||||||
|
Loading…
Reference in New Issue
Block a user