@@ -227,7 +227,7 @@ goal_polymorphic =
227 do ty <- goal
227 do ty <- goal
228 case ty of
228 case ty of
229 P _ n _ -> do env <- get_env
229 P _ n _ -> do env <- get_env
230− case lookup n env of
230+ case lookupBinder n env of
231 Nothing -> return False
231 Nothing -> return False
232 _ -> return True
232 _ -> return True
233 _ -> return False
233 _ -> return False
@@ -351,7 +351,7 @@ elab ist info emode opts fn tm
351 notDelay _ = True
351 notDelay _ = True
353 local f = do e <- get_env
353 local f = do e <- get_env
354− return (f `elem` map fst e)
354+ return (f `elem` map fstEnv e)
356 -- | Is a constant a type?
356 -- | Is a constant a type?
357 constType :: Const -> Bool
357 constType :: Const -> Bool
@@ -760,7 +760,7 @@ elab ist info emode opts fn tm
760 (ivs' \\ ivs)
760 (ivs' \\ ivs)
761 -- HACK: If the name leaks into its type, it may leak out of
761 -- HACK: If the name leaks into its type, it may leak out of
762 -- scope outside, so substitute in the outer scope.
762 -- scope outside, so substitute in the outer scope.
763− expandLet n (case lookup n env of
763+ expandLet n (case lookupBinder n env of
764 Just (Let t v) -> v
764 Just (Let t v) -> v
765 other -> error ("Value not a let binding: " ++ show other))
765 other -> error ("Value not a let binding: " ++ show other))
@@ -813,7 +813,7 @@ elab ist info emode opts fn tm
813 fnTy ((x, (_, xt)) : xs) ret = RBind x (Pi Nothing xt RType) (fnTy xs ret)
813 fnTy ((x, (_, xt)) : xs) ret = RBind x (Pi Nothing xt RType) (fnTy xs ret)
815 localVar env (PRef _ _ x)
815 localVar env (PRef _ _ x)
816− = case lookup x env of
816+ = case lookupBinder x env of
817 Just _ -> Just x
817 Just _ -> Just x
818 _ -> Nothing
818 _ -> Nothing
819 localVar env _ = Nothing
819 localVar env _ = Nothing
@@ -856,7 +856,7 @@ elab ist info emode opts fn tm
856 && isTConName f (tt_ctxt ist)) $
856 && isTConName f (tt_ctxt ist)) $
857 lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
857 lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
858-- trace (show (f, args_in, args)) $
858-- trace (show (f, args_in, args)) $
859− if (f `elem` map fst env && length args == 1 && length args_in == 1)
859+ if (f `elem` map fstEnv env && length args == 1 && length args_in == 1)
860 then -- simple app, as below
860 then -- simple app, as below
861 do simple_app False
861 do simple_app False
862 (elabE (ina { e_isfn = True }) (Just fc) (PRef ffc hls f))
862 (elabE (ina { e_isfn = True }) (Just fc) (PRef ffc hls f))
@@ -904,7 +904,7 @@ elab ist info emode opts fn tm
904 imp <- if (e_isfn ina) then
904 imp <- if (e_isfn ina) then
905 do guess <- get_guess
905 do guess <- get_guess
906 env <- get_env
906 env <- get_env
907− case safeForgetEnv (map fst env) guess of
907+ case safeForgetEnv (map fstEnv env) guess of
908 Nothing ->
908 Nothing ->
909 return []
909 return []
910 Just rguess -> do
910 Just rguess -> do
@@ -963,7 +963,7 @@ elab ist info emode opts fn tm
964 checkIfInjective n = do
964 checkIfInjective n = do
965 env <- get_env
965 env <- get_env
966− case lookup n env of
966+ case lookupBinder n env of
967 Nothing -> return ()
967 Nothing -> return ()
968 Just b ->
968 Just b ->
969 case unApply (whnf (tt_ctxt ist) env (binderTy b)) of
969 case unApply (whnf (tt_ctxt ist) env (binderTy b)) of
@@ -1079,13 +1079,13 @@ elab ist info emode opts fn tm
1079 -- unnecessarily (can only do this for unique things, since we
1079 -- unnecessarily (can only do this for unique things, since we
1080 -- assume they don't appear implicitly in types)
1080 -- assume they don't appear implicitly in types)
1081 ptm <- get_term
1081 ptm <- get_term
1082− let inOpts = (filter (/= scvn) (map fst args)) \\ (concatMap (\x -> allNamesIn (snd x)) opts)
1082+ let inOpts = (filter (/= scvn) (map fstEnv args)) \\ (concatMap (\x -> allNamesIn (snd x)) opts)
1084 let argsDropped = filter (isUnique envU)
1084 let argsDropped = filter (isUnique envU)
1085 (nub $ allNamesIn scr ++ inApp ptm ++
1085 (nub $ allNamesIn scr ++ inApp ptm ++
1088− let args' = filter (\(n, _) -> n `notElem` argsDropped) args
1088+ let args' = filter (\(n, _, _) -> n `notElem` argsDropped) args
1091 cname' <- defer argsDropped (mkN (mkCaseName fc fn))
1091 cname' <- defer argsDropped (mkN (mkCaseName fc fn))
@@ -1136,8 +1136,8 @@ elab ist info emode opts fn tm
1136 Just u -> u
1136 Just u -> u
1137 _ -> False
1137 _ -> False
1139− getKind env (n, _)
1139+ getKind env (n, _, _)
1140− = case lookup n env of
1140+ = case lookupBinder n env of
1141 Nothing -> return (n, False) -- can't happen, actually...
1141 Nothing -> return (n, False) -- can't happen, actually...
1142 Just b ->
1142 Just b ->
1143 do ty <- get_type (forget (binderTy b))
1143 do ty <- get_type (forget (binderTy b))
@@ -1220,13 +1220,13 @@ elab ist info emode opts fn tm
1220 loadState
1220 loadState
1221 updateAux (\aux -> aux { highlighting = hs })
1221 updateAux (\aux -> aux { highlighting = hs })
1223− let quoted = fmap (explicitNames . binderVal) $ lookup nTm env
1223+ let quoted = fmap (explicitNames . binderVal) $ lookupBinder nTm env
1224 isRaw = case unApply (normaliseAll ctxt env finalTy) of
1224 isRaw = case unApply (normaliseAll ctxt env finalTy) of
1225 (P _ n _, []) | n == reflm "Raw" -> True
1225 (P _ n _, []) | n == reflm "Raw" -> True
1226 _ -> False
1226 _ -> False
1227 case quoted of
1227 case quoted of
1228 Just q -> do ctxt <- get_context
1228 Just q -> do ctxt <- get_context
1229− (q', _, _) <- lift $ recheck (constraintNS info) ctxt [(uq, Lam Erased) | uq <- unquoteNames] (forget q) q
1229+ (q', _, _) <- lift $ recheck (constraintNS info) ctxt [(uq, Rig0, Lam Erased) | uq <- unquoteNames] (forget q) q
1230 if pattern
1230 if pattern
1231 then if isRaw
1231 then if isRaw
1232 then reflectRawQuotePattern unquoteNames (forget q')
1232 then reflectRawQuotePattern unquoteNames (forget q')
@@ -1255,7 +1255,7 @@ elab ist info emode opts fn tm
1255 elab' ina fc (PQuoteName n True nfc) =
1255 elab' ina fc (PQuoteName n True nfc) =
1256 do ctxt <- get_context
1256 do ctxt <- get_context
1257 env <- get_env
1257 env <- get_env
1258− case lookup n env of
1258+ case lookupBinder n env of
1259 Just _ -> do fill $ reflectName n
1259 Just _ -> do fill $ reflectName n
1261 highlightSource nfc (AnnBoundName n False)
1261 highlightSource nfc (AnnBoundName n False)
@@ -1324,7 +1324,7 @@ elab ist info emode opts fn tm
1324 env <- get_env
1324 env <- get_env
1325 ctxt <- get_context
1325 ctxt <- get_context
1326 let v = fmap (normaliseAll ctxt env . finalise . binderVal)
1326 let v = fmap (normaliseAll ctxt env . finalise . binderVal)
1327− (lookup n env)
1327+ (lookupBinder n env)
1328 loadState -- we have the highlighting - re-elaborate the value
1328 loadState -- we have the highlighting - re-elaborate the value
1329 elab' ina fc tm
1329 elab' ina fc tm
1330 case v of
1330 case v of
@@ -1347,9 +1347,9 @@ elab ist info emode opts fn tm
1347 delayElab pri t
1347 delayElab pri t
1348 = updateAux (\e -> e { delayed_elab = delayed_elab e ++ [(pri, t)] })
1348 = updateAux (\e -> e { delayed_elab = delayed_elab e ++ [(pri, t)] })
1350− isScr :: PTerm -> (Name, Binder Term) -> (Name, (Bool, Binder Term))
1350+ isScr :: PTerm -> (Name, RigCount, Binder Term) -> (Name, (Bool, Binder Term))
1351− isScr (PRef _ _ n) (n', b) = (n', (n == n', b))
1351+ isScr (PRef _ _ n) (n', _, b) = (n', (n == n', b))
1352− isScr _ (n', b) = (n', (False, b))
1352+ isScr _ (n', _, b) = (n', (False, b))
1354 caseBlock :: FC -> Name
1354 caseBlock :: FC -> Name
1355 -> PTerm -- original scrutinee
1355 -> PTerm -- original scrutinee
@@ -1449,8 +1449,8 @@ elab ist info emode opts fn tm
1449 mkDelay env (PAlternative ms b xs) = PAlternative ms b (map (mkDelay env) xs)
1449 mkDelay env (PAlternative ms b xs) = PAlternative ms b (map (mkDelay env) xs)
1450 mkDelay env t
1450 mkDelay env t
1451 = let fc = fileFC "Delay" in
1451 = let fc = fileFC "Delay" in
1452− addImplBound ist (map fst env) (PApp fc (PRef fc [] (sUN "Delay"))
1452+ addImplBound ist (map fstEnv env) (PApp fc (PRef fc [] (sUN "Delay"))
1453− [pexp t])
1453+ [pexp t])
1456 -- Don't put implicit coercions around applications which are marked
1456 -- Don't put implicit coercions around applications which are marked
@@ -1475,7 +1475,7 @@ elab ist info emode opts fn tm
1475 case fullApp tm of
1475 case fullApp tm of
1476 -- if f is global, leave it alone because we've already
1476 -- if f is global, leave it alone because we've already
1477 -- expanded it to the right arity
1477 -- expanded it to the right arity
1478− PApp fc ftm@(PRef _ _ f) args | Just aty <- lookup f env ->
1478+ PApp fc ftm@(PRef _ _ f) args | Just aty <- lookupBinder f env ->
1479 do let a = length (getArgTys (normalise (tt_ctxt ist) env (binderTy aty)))
1479 do let a = length (getArgTys (normalise (tt_ctxt ist) env (binderTy aty)))
1480 return (mkPApp fc a ftm args)
1480 return (mkPApp fc a ftm args)
1481 _ -> return tm
1481 _ -> return tm
@@ -1528,7 +1528,7 @@ elab ist info emode opts fn tm
1528 mkCoerce env (PAlternative ms aty tms) n
1528 mkCoerce env (PAlternative ms aty tms) n
1529 = PAlternative ms aty (map (\t -> mkCoerce env t n) tms)
1529 = PAlternative ms aty (map (\t -> mkCoerce env t n) tms)
1530 mkCoerce env t n = let fc = maybe (fileFC "Coercion") id (highestFC t) in
1530 mkCoerce env t n = let fc = maybe (fileFC "Coercion") id (highestFC t) in
1531− addImplBound ist (map fst env)
1531+ addImplBound ist (map fstEnv env)
1532 (PApp fc (PRef fc [] n) [pexp (PCoerced t)])
1532 (PApp fc (PRef fc [] n) [pexp (PCoerced t)])
1534 -- | Elaborate the arguments to a function
1534 -- | Elaborate the arguments to a function
@@ -1647,7 +1647,7 @@ pruneByType imp env t goalty c as
1647 locallyBound [] = Nothing
1647 locallyBound [] = Nothing
1648 locallyBound (t:ts)
1648 locallyBound (t:ts)
1649 | Just n <- getName t,
1649 | Just n <- getName t,
1650− n `elem` map fst env = Just t
1650+ n `elem` map fstEnv env = Just t
1651 | otherwise = locallyBound ts
1651 | otherwise = locallyBound ts
1652 getName (PRef _ _ n) = Just n
1652 getName (PRef _ _ n) = Just n
1653 getName (PApp _ (PRef _ _ (UN l)) [_, _, arg]) -- ignore Delays
1653 getName (PApp _ (PRef _ _ (UN l)) [_, _, arg]) -- ignore Delays
@@ -1800,7 +1800,7 @@ isPlausible ist var env n ty
1800findHighlight :: Name -> ElabD OutputAnnotation
1800findHighlight :: Name -> ElabD OutputAnnotation
1801findHighlight n = do ctxt <- get_context
1801findHighlight n = do ctxt <- get_context
1802 env <- get_env
1802 env <- get_env
1803− case lookup n env of
1803+ case lookupBinder n env of
1804 Just _ -> return $ AnnBoundName n False
1804 Just _ -> return $ AnnBoundName n False
1805 Nothing -> case lookupTyExact n ctxt of
1805 Nothing -> case lookupTyExact n ctxt of
1806 Just _ -> return $ AnnName n Nothing Nothing Nothing
1806 Just _ -> return $ AnnName n Nothing Nothing Nothing
@@ -1820,7 +1820,7 @@ solveAuto ist fn ambigok (n, failc)
1820 when (not isg) $
1820 when (not isg) $
1821 proofSearch' ist True ambigok 100 True Nothing fn [] [])
1821 proofSearch' ist True ambigok 100 True Nothing fn [] [])
1822 (lift $ Error (addLoc failc
1822 (lift $ Error (addLoc failc
1823− (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env))))
1823+ (CantSolveGoal g (map (\(n, _, b) -> (n, binderTy b)) env))))
1824 return ()
1824 return ()
1825 where addLoc (FailContext fc f x : prev) err
1825 where addLoc (FailContext fc f x : prev) err
1826 = At fc (ElaboratingArg f x
1826 = At fc (ElaboratingArg f x
@@ -1893,7 +1893,7 @@ case_ ind autoSolve ist fn tm = do
1893 focus valn
1893 focus valn
1894 elab ist toplevel ERHS [] (sMN 0 "tac") tm
1894 elab ist toplevel ERHS [] (sMN 0 "tac") tm
1895 env <- get_env
1895 env <- get_env
1896− let (Just binding) = lookup letn env
1896+ let (Just binding) = lookupBinder letn env
1897 let val = binderVal binding
1897 let val = binderVal binding
1898 if ind then induction (forget val)
1898 if ind then induction (forget val)
1899 else casetac (forget val)
1899 else casetac (forget val)
@@ -2456,11 +2456,11 @@ runTac :: Bool -> IState -> Maybe FC -> Name -> PTactic -> ElabD ()
2456runTac autoSolve ist perhapsFC fn tac
2456runTac autoSolve ist perhapsFC fn tac
2457 = do env <- get_env
2457 = do env <- get_env
2458 g <- goal
2458 g <- goal
2459− let tac' = fmap (addImplBound ist (map fst env)) tac
2459+ let tac' = fmap (addImplBound ist (map fstEnv env)) tac
2460 if autoSolve
2460 if autoSolve
2461 then runT tac'
2461 then runT tac'
2462 else no_errors (runT tac')
2462 else no_errors (runT tac')
2463− (Just (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env)))
2463+ (Just (CantSolveGoal g (map (\(n, _, b) -> (n, binderTy b)) env)))
2465 runT (Intro []) = do g <- goal
2465 runT (Intro []) = do g <- goal
2466 attack; intro (bname g)
2466 attack; intro (bname g)
@@ -2490,7 +2490,7 @@ runTac autoSolve ist perhapsFC fn tac
2490 tryAll tacs
2490 tryAll tacs
2491 when autoSolve solveAll
2491 when autoSolve solveAll
2492 where envArgs n = do e <- get_env
2492 where envArgs n = do e <- get_env
2493− case lookup n e of
2493+ case lookupBinder n e of
2494 Just t -> return $ map (const False)
2494 Just t -> return $ map (const False)
2495 (getArgTys (binderTy t))
2495 (getArgTys (binderTy t))
2496 _ -> return []
2496 _ -> return []
@@ -2508,7 +2508,7 @@ runTac autoSolve ist perhapsFC fn tac
2508 where isImp (PImp _ _ _ _ _) = True
2508 where isImp (PImp _ _ _ _ _) = True
2509 isImp _ = False
2509 isImp _ = False
2510 envArgs n = do e <- get_env
2510 envArgs n = do e <- get_env
2511− case lookup n e of
2511+ case lookupBinder n e of
2512 Just t -> return $ map (const False)
2512 Just t -> return $ map (const False)
2513 (getArgTys (binderTy t))
2513 (getArgTys (binderTy t))
2514 _ -> return []
2514 _ -> return []