@@ -227,7 +227,7 @@ goal_polymorphic =
227227 do ty <- goal
228228 case ty of
229229 P _ n _ -> do env <- get_env
230− case lookup n env of
230+ case lookupBinder n env of
231231 Nothing -> return False
232232 _ -> return True
233233 _ -> return False
@@ -351,7 +351,7 @@ elab ist info emode opts fn tm
351351 notDelay _ = True
352352
353353 local f = do e <- get_env
354− return (f `elem` map fst e)
354+ return (f `elem` map fstEnv e)
355355
356356 -- | Is a constant a type?
357357 constType :: Const -> Bool
@@ -760,7 +760,7 @@ elab ist info emode opts fn tm
760760 (ivs' \\ ivs)
761761 -- HACK: If the name leaks into its type, it may leak out of
762762 -- scope outside, so substitute in the outer scope.
763− expandLet n (case lookup n env of
763+ expandLet n (case lookupBinder n env of
764764 Just (Let t v) -> v
765765 other -> error ("Value not a let binding: " ++ show other))
766766 solve
@@ -813,7 +813,7 @@ elab ist info emode opts fn tm
813813 fnTy ((x, (_, xt)) : xs) ret = RBind x (Pi Nothing xt RType) (fnTy xs ret)
814814
815815 localVar env (PRef _ _ x)
816− = case lookup x env of
816+ = case lookupBinder x env of
817817 Just _ -> Just x
818818 _ -> Nothing
819819 localVar env _ = Nothing
@@ -856,7 +856,7 @@ elab ist info emode opts fn tm
856856 && isTConName f (tt_ctxt ist)) $
857857 lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
858858-- 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)
860860 then -- simple app, as below
861861 do simple_app False
862862 (elabE (ina { e_isfn = True }) (Just fc) (PRef ffc hls f))
@@ -904,7 +904,7 @@ elab ist info emode opts fn tm
904904 imp <- if (e_isfn ina) then
905905 do guess <- get_guess
906906 env <- get_env
907− case safeForgetEnv (map fst env) guess of
907+ case safeForgetEnv (map fstEnv env) guess of
908908 Nothing ->
909909 return []
910910 Just rguess -> do
@@ -963,7 +963,7 @@ elab ist info emode opts fn tm
963963
964964 checkIfInjective n = do
965965 env <- get_env
966− case lookup n env of
966+ case lookupBinder n env of
967967 Nothing -> return ()
968968 Just b ->
969969 case unApply (whnf (tt_ctxt ist) env (binderTy b)) of
@@ -1079,13 +1079,13 @@ elab ist info emode opts fn tm
10791079 -- unnecessarily (can only do this for unique things, since we
10801080 -- assume they don't appear implicitly in types)
10811081 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)
10831083
10841084 let argsDropped = filter (isUnique envU)
10851085 (nub $ allNamesIn scr ++ inApp ptm ++
10861086 inOpts)
10871087
1088− let args' = filter (\(n, _) -> n `notElem` argsDropped) args
1088+ let args' = filter (\(n, _, _) -> n `notElem` argsDropped) args
10891089
10901090 attack
10911091 cname' <- defer argsDropped (mkN (mkCaseName fc fn))
@@ -1136,8 +1136,8 @@ elab ist info emode opts fn tm
11361136 Just u -> u
11371137 _ -> False
11381138
1139− getKind env (n, _)
1140− = case lookup n env of
1139+ getKind env (n, _, _)
1140+ = case lookupBinder n env of
11411141 Nothing -> return (n, False) -- can't happen, actually...
11421142 Just b ->
11431143 do ty <- get_type (forget (binderTy b))
@@ -1220,13 +1220,13 @@ elab ist info emode opts fn tm
12201220 loadState
12211221 updateAux (\aux -> aux { highlighting = hs })
12221222
1223− let quoted = fmap (explicitNames . binderVal) $ lookup nTm env
1223+ let quoted = fmap (explicitNames . binderVal) $ lookupBinder nTm env
12241224 isRaw = case unApply (normaliseAll ctxt env finalTy) of
12251225 (P _ n _, []) | n == reflm "Raw" -> True
12261226 _ -> False
12271227 case quoted of
12281228 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
12301230 if pattern
12311231 then if isRaw
12321232 then reflectRawQuotePattern unquoteNames (forget q')
@@ -1255,7 +1255,7 @@ elab ist info emode opts fn tm
12551255 elab' ina fc (PQuoteName n True nfc) =
12561256 do ctxt <- get_context
12571257 env <- get_env
1258− case lookup n env of
1258+ case lookupBinder n env of
12591259 Just _ -> do fill $ reflectName n
12601260 solve
12611261 highlightSource nfc (AnnBoundName n False)
@@ -1324,7 +1324,7 @@ elab ist info emode opts fn tm
13241324 env <- get_env
13251325 ctxt <- get_context
13261326 let v = fmap (normaliseAll ctxt env . finalise . binderVal)
1327− (lookup n env)
1327+ (lookupBinder n env)
13281328 loadState -- we have the highlighting - re-elaborate the value
13291329 elab' ina fc tm
13301330 case v of
@@ -1347,9 +1347,9 @@ elab ist info emode opts fn tm
13471347 delayElab pri t
13481348 = updateAux (\e -> e { delayed_elab = delayed_elab e ++ [(pri, t)] })
13491349
1350− isScr :: PTerm -> (Name, Binder Term) -> (Name, (Bool, Binder Term))
1351− isScr (PRef _ _ n) (n', b) = (n', (n == n', b))
1352− isScr _ (n', b) = (n', (False, b))
1350+ isScr :: PTerm -> (Name, RigCount, Binder Term) -> (Name, (Bool, Binder Term))
1351+ isScr (PRef _ _ n) (n', _, b) = (n', (n == n', b))
1352+ isScr _ (n', _, b) = (n', (False, b))
13531353
13541354 caseBlock :: FC -> Name
13551355 -> PTerm -- original scrutinee
@@ -1449,8 +1449,8 @@ elab ist info emode opts fn tm
14491449 mkDelay env (PAlternative ms b xs) = PAlternative ms b (map (mkDelay env) xs)
14501450 mkDelay env t
14511451 = let fc = fileFC "Delay" in
1452− addImplBound ist (map fst env) (PApp fc (PRef fc [] (sUN "Delay"))
1453− [pexp t])
1452+ addImplBound ist (map fstEnv env) (PApp fc (PRef fc [] (sUN "Delay"))
1453+ [pexp t])
14541454
14551455
14561456 -- Don't put implicit coercions around applications which are marked
@@ -1475,7 +1475,7 @@ elab ist info emode opts fn tm
14751475 case fullApp tm of
14761476 -- if f is global, leave it alone because we've already
14771477 -- 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 ->
14791479 do let a = length (getArgTys (normalise (tt_ctxt ist) env (binderTy aty)))
14801480 return (mkPApp fc a ftm args)
14811481 _ -> return tm
@@ -1528,7 +1528,7 @@ elab ist info emode opts fn tm
15281528 mkCoerce env (PAlternative ms aty tms) n
15291529 = PAlternative ms aty (map (\t -> mkCoerce env t n) tms)
15301530 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)
15321532 (PApp fc (PRef fc [] n) [pexp (PCoerced t)])
15331533
15341534 -- | Elaborate the arguments to a function
@@ -1647,7 +1647,7 @@ pruneByType imp env t goalty c as
16471647 locallyBound [] = Nothing
16481648 locallyBound (t:ts)
16491649 | Just n <- getName t,
1650− n `elem` map fst env = Just t
1650+ n `elem` map fstEnv env = Just t
16511651 | otherwise = locallyBound ts
16521652 getName (PRef _ _ n) = Just n
16531653 getName (PApp _ (PRef _ _ (UN l)) [_, _, arg]) -- ignore Delays
@@ -1800,7 +1800,7 @@ isPlausible ist var env n ty
18001800findHighlight :: Name -> ElabD OutputAnnotation
18011801findHighlight n = do ctxt <- get_context
18021802 env <- get_env
1803− case lookup n env of
1803+ case lookupBinder n env of
18041804 Just _ -> return $ AnnBoundName n False
18051805 Nothing -> case lookupTyExact n ctxt of
18061806 Just _ -> return $ AnnName n Nothing Nothing Nothing
@@ -1820,7 +1820,7 @@ solveAuto ist fn ambigok (n, failc)
18201820 when (not isg) $
18211821 proofSearch' ist True ambigok 100 True Nothing fn [] [])
18221822 (lift $ Error (addLoc failc
1823− (CantSolveGoal g (map (\(n, b) -> (n, binderTy b)) env))))
1823+ (CantSolveGoal g (map (\(n, _, b) -> (n, binderTy b)) env))))
18241824 return ()
18251825 where addLoc (FailContext fc f x : prev) err
18261826 = At fc (ElaboratingArg f x
@@ -1893,7 +1893,7 @@ case_ ind autoSolve ist fn tm = do
18931893 focus valn
18941894 elab ist toplevel ERHS [] (sMN 0 "tac") tm
18951895 env <- get_env
1896− let (Just binding) = lookup letn env
1896+ let (Just binding) = lookupBinder letn env
18971897 let val = binderVal binding
18981898 if ind then induction (forget val)
18991899 else casetac (forget val)
@@ -2456,11 +2456,11 @@ runTac :: Bool -> IState -> Maybe FC -> Name -> PTactic -> ElabD ()
24562456runTac autoSolve ist perhapsFC fn tac
24572457 = do env <- get_env
24582458 g <- goal
2459− let tac' = fmap (addImplBound ist (map fst env)) tac
2459+ let tac' = fmap (addImplBound ist (map fstEnv env)) tac
24602460 if autoSolve
24612461 then runT tac'
24622462 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)))
24642464 where
24652465 runT (Intro []) = do g <- goal
24662466 attack; intro (bname g)
@@ -2490,7 +2490,7 @@ runTac autoSolve ist perhapsFC fn tac
24902490 tryAll tacs
24912491 when autoSolve solveAll
24922492 where envArgs n = do e <- get_env
2493− case lookup n e of
2493+ case lookupBinder n e of
24942494 Just t -> return $ map (const False)
24952495 (getArgTys (binderTy t))
24962496 _ -> return []
@@ -2508,7 +2508,7 @@ runTac autoSolve ist perhapsFC fn tac
25082508 where isImp (PImp _ _ _ _ _) = True
25092509 isImp _ = False
25102510 envArgs n = do e <- get_env
2511− case lookup n e of
2511+ case lookupBinder n e of
25122512 Just t -> return $ map (const False)
25132513 (getArgTys (binderTy t))
25142514 _ -> return []