@@ -38,7 +38,7 @@ mkPatTm t = do i <- getIState
38 evalStateT (toTT timp) 0
38 evalStateT (toTT timp) 0
40 toTT (PRef _ n) = do i <- lift getIState
40 toTT (PRef _ n) = do i <- lift getIState
41− case lookupDef Nothing n (tt_ctxt i) of
41+ case lookupDef n (tt_ctxt i) of
42 [TyDecl nt _] -> return $ P nt n Erased
42 [TyDecl nt _] -> return $ P nt n Erased
43 _ -> return $ P Ref n Erased
43 _ -> return $ P Ref n Erased
44 toTT (PApp _ t args) = do t' <- toTT t
44 toTT (PApp _ t args) = do t' <- toTT t
@@ -107,9 +107,9 @@ expandAlts :: IState -> [CaseAlt] -> SC -> Idris [CaseAlt]
107expandAlts i all@(ConstCase c _ : alts) def
107expandAlts i all@(ConstCase c _ : alts) def
108 = return $ all ++ [DefaultCase def]
108 = return $ all ++ [DefaultCase def]
109expandAlts i all@(ConCase n _ _ _ : alts) def
109expandAlts i all@(ConCase n _ _ _ : alts) def
110− | (TyDecl c@(DCon _ arity) ty : _) <- lookupDef Nothing n (tt_ctxt i)
110+ | (TyDecl c@(DCon _ arity) ty : _) <- lookupDef n (tt_ctxt i)
111 = do let tyn = getTy n (tt_ctxt i)
111 = do let tyn = getTy n (tt_ctxt i)
112− case lookupCtxt Nothing tyn (idris_datatypes i) of
112+ case lookupCtxt tyn (idris_datatypes i) of
113 (TI ns _ _: _) -> do let ps = map mkPat ns
113 (TI ns _ _: _) -> do let ps = map mkPat ns
114 return $ addAlts ps (altsFor all) all
114 return $ addAlts ps (altsFor all) all
115 _ -> return all
115 _ -> return all
@@ -127,13 +127,13 @@ expandAlts i all@(ConCase n _ _ _ : alts) def
127 argList i = take i (map (\x -> (MN x "ign")) [0..])
127 argList i = take i (map (\x -> (MN x "ign")) [0..])
129 getTy n ctxt
129 getTy n ctxt
130− = case lookupTy Nothing n ctxt of
130+ = case lookupTy n ctxt of
131 (t : _) -> case unApply (getRetTy t) of
131 (t : _) -> case unApply (getRetTy t) of
132 (P _ tyn _, _) -> tyn
132 (P _ tyn _, _) -> tyn
133 x -> error $ "Can't happen getTy 1 " ++ show (n, x)
133 x -> error $ "Can't happen getTy 1 " ++ show (n, x)
134 _ -> error "Can't happen getTy 2"
134 _ -> error "Can't happen getTy 2"
136− mkPat x = case lookupCtxt Nothing x (idris_implicits i) of
136+ mkPat x = case lookupCtxt x (idris_implicits i) of
137 (pargs : _)
137 (pargs : _)
138 -> (x, length pargs)
138 -> (x, length pargs)
139 _ -> error "Can't happen - genAll"
139 _ -> error "Can't happen - genAll"
@@ -160,7 +160,7 @@ genClauses fc n xs given
160 logLvl 10 $ show argss ++ "\n" ++ show all_args
160 logLvl 10 $ show argss ++ "\n" ++ show all_args
161 logLvl 10 $ "Original: \n" ++
161 logLvl 10 $ "Original: \n" ++
162 showSep "\n" (map (\t -> showImp True (delab' i t True)) xs)
162 showSep "\n" (map (\t -> showImp True (delab' i t True)) xs)
163− let parg = case lookupCtxt Nothing n (idris_implicits i) of
163+ let parg = case lookupCtxt n (idris_implicits i) of
164 (p : _) -> p
164 (p : _) -> p
165 _ -> repeat (pexp Placeholder)
165 _ -> repeat (pexp Placeholder)
166 let tryclauses = mkClauses parg all_args
166 let tryclauses = mkClauses parg all_args
@@ -217,8 +217,8 @@ genAll i args = case filter (/=Placeholder) $ concatMap otherPats (nub args) of
217 [] -> [Placeholder]
217 [] -> [Placeholder]
218 xs -> nub xs
218 xs -> nub xs
220− conForm (PApp _ (PRef fc n) _) = isConName Nothing n (tt_ctxt i)
220+ conForm (PApp _ (PRef fc n) _) = isConName n (tt_ctxt i)
221− conForm (PRef fc n) = isConName Nothing n (tt_ctxt i)
221+ conForm (PRef fc n) = isConName n (tt_ctxt i)
222 conForm _ = False
222 conForm _ = False
224 otherPats :: PTerm -> [PTerm]
224 otherPats :: PTerm -> [PTerm]
@@ -227,22 +227,22 @@ genAll i args = case filter (/=Placeholder) $ concatMap otherPats (nub args) of
227 otherPats arg = return Placeholder
227 otherPats arg = return Placeholder
229 ops fc n xs o
229 ops fc n xs o
230− | (TyDecl c@(DCon _ arity) ty : _) <- lookupDef Nothing n (tt_ctxt i)
230+ | (TyDecl c@(DCon _ arity) ty : _) <- lookupDef n (tt_ctxt i)
231 = do xs' <- mapM otherPats (map getTm xs)
231 = do xs' <- mapM otherPats (map getTm xs)
232 let p = PApp fc (PRef fc n) (zipWith upd xs' xs)
232 let p = PApp fc (PRef fc n) (zipWith upd xs' xs)
233 let tyn = getTy n (tt_ctxt i)
233 let tyn = getTy n (tt_ctxt i)
234− case lookupCtxt Nothing tyn (idris_datatypes i) of
234+ case lookupCtxt tyn (idris_datatypes i) of
235 (TI ns _ _ : _) -> p : map (mkPat fc) (ns \\ [n])
235 (TI ns _ _ : _) -> p : map (mkPat fc) (ns \\ [n])
237 ops fc n arg o = return Placeholder
237 ops fc n arg o = return Placeholder
239− getTy n ctxt = case lookupTy Nothing n ctxt of
239+ getTy n ctxt = case lookupTy n ctxt of
240 (t : _) -> case unApply (getRetTy t) of
240 (t : _) -> case unApply (getRetTy t) of
241 (P _ tyn _, _) -> tyn
241 (P _ tyn _, _) -> tyn
242 x -> error $ "Can't happen getTy 1 " ++ show (n, x)
242 x -> error $ "Can't happen getTy 1 " ++ show (n, x)
243 _ -> error "Can't happen getTy 2"
243 _ -> error "Can't happen getTy 2"
245− mkPat fc x = case lookupCtxt Nothing x (idris_implicits i) of
245+ mkPat fc x = case lookupCtxt x (idris_implicits i) of
246 (pargs : _)
246 (pargs : _)
247 -> PApp fc (PRef fc x) (map (upd Placeholder) pargs)
247 -> PApp fc (PRef fc x) (map (upd Placeholder) pargs)
248 _ -> error "Can't happen - genAll"
248 _ -> error "Can't happen - genAll"
@@ -306,7 +306,7 @@ calcProd i fc n pats = do patsprod <- mapM prodRec pats
307 cotype ty
307 cotype ty
308 | (P _ t _, _) <- unApply (getRetTy ty)
308 | (P _ t _, _) <- unApply (getRetTy ty)
309− = case lookupCtxt Nothing t (idris_datatypes i) of
309+ = case lookupCtxt t (idris_datatypes i) of
310 [TI _ True _] -> True
310 [TI _ True _] -> True
311 _ -> False
311 _ -> False
312 | otherwise = False
312 | otherwise = False
@@ -315,7 +315,7 @@ calcTotality :: [Name] -> FC -> Name -> [([Name], Term, Term)]
315 -> Idris Totality
315 -> Idris Totality
316calcTotality path fc n pats
316calcTotality path fc n pats
317 = do i <- getIState
317 = do i <- getIState
318− let opts = case lookupCtxt Nothing n (idris_flags i) of
318+ let opts = case lookupCtxt n (idris_flags i) of
319 [fs] -> fs
319 [fs] -> fs
321 case mapMaybe (checkLHS i) (map (\ (_, l, r) -> l) pats) of
321 case mapMaybe (checkLHS i) (map (\ (_, l, r) -> l) pats) of
@@ -339,12 +339,12 @@ checkTotality path fc n
339 updateContext (simplifyCasedef n)
339 updateContext (simplifyCasedef n)
340 ctxt <- getContext
340 ctxt <- getContext
341 i <- getIState
341 i <- getIState
342− let opts = case lookupCtxt Nothing n (idris_flags i) of
342+ let opts = case lookupCtxt n (idris_flags i) of
343 [fs] -> fs
343 [fs] -> fs
345 t' <- case t of
345 t' <- case t of
346 Unchecked ->
346 Unchecked ->
347− case lookupDef Nothing n ctxt of
347+ case lookupDef n ctxt of
348 [CaseOp _ _ _ _ pats _ _ _ _] ->
348 [CaseOp _ _ _ _ pats _ _ _ _] ->
349 do t' <- if AssertTotal `elem` opts
349 do t' <- if AssertTotal `elem` opts
350 then return $ Total []
350 then return $ Total []
@@ -378,7 +378,7 @@ checkTotality path fc n
379 warnPartial n t
379 warnPartial n t
380 = do i <- getIState
380 = do i <- getIState
381− case lookupDef Nothing n (tt_ctxt i) of
381+ case lookupDef n (tt_ctxt i) of
382 [x] -> do
382 [x] -> do
383 iputStrLn $ show fc ++ ":Warning - " ++ show n ++ " is " ++ show t
383 iputStrLn $ show fc ++ ":Warning - " ++ show n ++ " is " ++ show t
384-- ++ "\n" ++ show x
384-- ++ "\n" ++ show x
@@ -407,8 +407,8 @@ checkDeclTotality (fc, n)
407buildSCG :: (FC, Name) -> Idris ()
407buildSCG :: (FC, Name) -> Idris ()
408buildSCG (_, n) = do
408buildSCG (_, n) = do
409 ist <- getIState
409 ist <- getIState
410− case lookupCtxt Nothing n (idris_callgraph ist) of
410+ case lookupCtxt n (idris_callgraph ist) of
411− [cg] -> case lookupDef Nothing n (tt_ctxt ist) of
411+ [cg] -> case lookupDef n (tt_ctxt ist) of
412 [CaseOp _ _ _ _ _ args sc _ _] ->
412 [CaseOp _ _ _ _ _ args sc _ _] ->
413 do logLvl 3 $ "Building SCG for " ++ show n ++ " from\n"
413 do logLvl 3 $ "Building SCG for " ++ show n ++ " from\n"
414 ++ show sc
414 ++ show sc
@@ -442,7 +442,7 @@ buildSCG' ist sc args = -- trace ("Building SCG for " ++ show sc) $
442 -- how the arguments relate - either Smaller or Unknown
442 -- how the arguments relate - either Smaller or Unknown
443 argRels :: Name -> [(Name, SizeChange)]
443 argRels :: Name -> [(Name, SizeChange)]
444 argRels n = let ctxt = tt_ctxt ist
444 argRels n = let ctxt = tt_ctxt ist
445− [ty] = lookupTy Nothing n ctxt -- must exist!
445+ [ty] = lookupTy n ctxt -- must exist!
446 P _ nty _ = fst (unApply (getRetTy ty))
446 P _ nty _ = fst (unApply (getRetTy ty))
447 args = map snd (getArgTys ty) in
447 args = map snd (getArgTys ty) in
448 map (getRel nty) (map (fst . unApply . getRetTy) args)
448 map (getRel nty) (map (fst . unApply . getRetTy) args)
@@ -503,7 +503,7 @@ buildSCG' ist sc args = -- trace ("Building SCG for " ++ show sc) $
503checkSizeChange :: Name -> Idris Totality
503checkSizeChange :: Name -> Idris Totality
504checkSizeChange n = do
504checkSizeChange n = do
505 ist <- getIState
505 ist <- getIState
506− case lookupCtxt Nothing n (idris_callgraph ist) of
506+ case lookupCtxt n (idris_callgraph ist) of
507 [cg] -> do let ms = mkMultiPaths ist [] (scg cg)
507 [cg] -> do let ms = mkMultiPaths ist [] (scg cg)
508 logLvl 5 ("Multipath for " ++ show n ++ ":\n" ++
508 logLvl 5 ("Multipath for " ++ show n ++ ":\n" ++
509 "from " ++ show (scg cg) ++ "\n" ++
509 "from " ++ show (scg cg) ++ "\n" ++
@@ -530,7 +530,7 @@ mkMultiPaths ist path cg
530 where extend (nextf, args)
530 where extend (nextf, args)
531 | (nextf, args) `elem` path = [ reverse ((nextf, args) : path) ]
531 | (nextf, args) `elem` path = [ reverse ((nextf, args) : path) ]
532 | [Unchecked] <- lookupTotal nextf (tt_ctxt ist)
532 | [Unchecked] <- lookupTotal nextf (tt_ctxt ist)
533− = case lookupCtxt Nothing nextf (idris_callgraph ist) of
533+ = case lookupCtxt nextf (idris_callgraph ist) of
534 [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
534 [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
535 _ -> [ reverse ((nextf, args) : path) ]
535 _ -> [ reverse ((nextf, args) : path) ]
536 | otherwise = [ reverse ((nextf, args) : path) ]
536 | otherwise = [ reverse ((nextf, args) : path) ]
@@ -538,7 +538,7 @@ mkMultiPaths ist path cg
538-- do (nextf, args) <- cg
538-- do (nextf, args) <- cg
539-- if ((nextf, args) `elem` path)
539-- if ((nextf, args) `elem` path)
540-- then return (reverse ((nextf, args) : path))
540-- then return (reverse ((nextf, args) : path))
541−-- else case lookupCtxt Nothing nextf (idris_callgraph ist) of
541+-- else case lookupCtxt nextf (idris_callgraph ist) of
542-- [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
542-- [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
543-- _ -> return (reverse ((nextf, args) : path))
543-- _ -> return (reverse ((nextf, args) : path))
@@ -562,12 +562,12 @@ checkMP ist i mp = if i > 0
562-- = Partial BelieveMe
562-- = Partial BelieveMe
563 -- if we get to a constructor, it's fine as long as it's strictly positive
563 -- if we get to a constructor, it's fine as long as it's strictly positive
564 tryPath desc path ((f, _) :es) arg
564 tryPath desc path ((f, _) :es) arg
565− | [TyDecl (DCon _ _) _] <- lookupDef Nothing f (tt_ctxt ist)
565+ | [TyDecl (DCon _ _) _] <- lookupDef f (tt_ctxt ist)
566 = case lookupTotal f (tt_ctxt ist) of
566 = case lookupTotal f (tt_ctxt ist) of
567 [Total _] -> Unchecked -- okay so far
567 [Total _] -> Unchecked -- okay so far
568 [Partial _] -> Partial (Other [f])
568 [Partial _] -> Partial (Other [f])
569 x -> error (show x)
569 x -> error (show x)
570− | [TyDecl (TCon _ _) _] <- lookupDef Nothing f (tt_ctxt ist)
570+ | [TyDecl (TCon _ _) _] <- lookupDef f (tt_ctxt ist)
571 = Total []
571 = Total []
572 tryPath desc path (e@(f, args) : es) arg
572 tryPath desc path (e@(f, args) : es) arg
573 | e `elem` es && allNothing args = Partial (Mutual [f])
573 | e `elem` es && allNothing args = Partial (Mutual [f])