1{-# LANGUAGE PatternGuards #-}
3module Idris.Coverage where
10import Idris.Delaborate
18import Control.Monad.State
20mkPatTm :: PTerm -> Idris Term
21mkPatTm t = do i <- getIState
22 let timp = addImpl' True [] [] i t
23 evalStateT (toTT timp) 0
25 toTT (PRef _ n) = do i <- lift getIState
26 case lookupDef n (tt_ctxt i) of
27 [TyDecl nt _] -> return $ P nt n Erased
28 _ -> return $ P Ref n Erased
29 toTT (PApp _ t args) = do t' <- toTT t
30 args' <- mapM (toTT . getTm) args
31 return $ mkApp t' args'
34 return (P Bound (MN v "imp") Erased)
36-- Given a list of LHSs, generate a extra clauses which cover the remaining
37-- cases. The ones which haven't been provided are marked 'absurd' so that the
38-- checker will make sure they can't happen.
40-- This will only work after the given clauses have been typechecked and the
41-- names are fully explicit!
43genClauses :: FC -> Name -> [Term] -> [PClause] -> Idris [PTerm]
44genClauses fc n xs given
46 let lhss = map (getLHS i) xs
47 let argss = transpose lhss
48 let all_args = map (genAll i) argss
49 logLvl 5 $ "COVERAGE of " ++ show n
50 logLvl 5 $ show (map length argss) ++ "\n" ++ show (map length all_args)
51 logLvl 10 $ show argss ++ "\n" ++ show all_args
52 logLvl 10 $ "Original: \n" ++
53 showSep "\n" (map (\t -> showImp Nothing True False (delab' i t True)) xs)
54 -- add an infinite supply of explicit arguments to update the possible
55 -- cases for (the return type may be variadic, or function type, sp
56 -- there may be more case splitting that the idris_implicits record
58 let parg = case lookupCtxt n (idris_implicits i) of
59 (p : _) -> p ++ repeat (PExp 0 False Placeholder "")
60 _ -> repeat (pexp Placeholder)
61 let tryclauses = mkClauses parg all_args
62 logLvl 2 $ show (length tryclauses) ++ " initially to check"
63 let new = filter (noMatch i) (mnub i tryclauses)
64 logLvl 1 $ show (length new) ++ " clauses to check for impossibility"
65 logLvl 5 $ "New clauses: \n" ++ showSep "\n" (map (showImp Nothing True False) new)
66-- ++ " from:\n" ++ showSep "\n" (map (showImp True) tryclauses)
68-- return (map (\t -> PClause n t [] PImpossible []) new)
70 | (f, args) <- unApply term = map (\t -> delab' i t True) args
73 lhsApp (PClause _ _ l _ _ _) = l
74 lhsApp (PWith _ _ l _ _ _) = l
78 let xs' = filter (\t -> case matchClause i x t of
83-- if (any (\t -> case matchClause i x t of
85-- Left _ -> False) xs) then mnub i xs
88 noMatch i tm = all (\x -> case matchClause i (delab' i x True) tm of
93 mkClauses :: [PArg] -> [[PTerm]] -> [PTerm]
95 | all (== [Placeholder]) args = []
97 = do args' <- mkArg args
98 let tm = PApp fc (PRef fc n) (zipWith upd args' parg)
101 mkArg :: [[PTerm]] -> [[PTerm]]
103 mkArg (a : as) = do a' <- a
109fnub' acc (x : xs) | x `qelem` acc = fnub' acc (filter (not.(quickEq x)) xs)
110 | otherwise = fnub' (x : acc) xs
113-- quick check for constructor equality
114quickEq :: PTerm -> PTerm -> Bool
115quickEq (PRef _ n) (PRef _ n') = n == n'
116quickEq (PApp _ t as) (PApp _ t' as')
117 | length as == length as'
118 = quickEq t t' && and (zipWith quickEq (map getTm as) (map getTm as'))
119quickEq Placeholder Placeholder = True
123qelem x (y : ys) | x `quickEq` y = True
124 | otherwise = qelem x ys
126-- FIXME: Just look for which one is the deepest, then generate all
127-- possibilities up to that depth.
129genAll :: IState -> [PTerm] -> [PTerm]
131 = case filter (/=Placeholder) $ fnub (concatMap otherPats (fnub args)) of
133 xs -> inventConsts xs
135 -- if they're constants, invent a new one to make sure that
136 -- constants which are not explicitly handled are covered
137 inventConsts cs@(PConstant c : _) = map PConstant (ic' (mapMaybe getConst cs))
138 where getConst (PConstant c) = Just c
142 -- try constants until they're not in the list.
143 -- FIXME: It is, of course, possible that someone has enumerated all
144 -- the constants and matched on them (maybe in generated code) and this
145 -- will be really slow. This is sufficiently unlikely that we won't
148 ic' xs@(I _ : _) = firstMissing xs (lotsOfNums I)
149 ic' xs@(BI _ : _) = firstMissing xs (lotsOfNums BI)
150 ic' xs@(Fl _ : _) = firstMissing xs (lotsOfNums Fl)
151 ic' xs@(B8 _ : _) = firstMissing xs (lotsOfNums B8)
152 ic' xs@(B16 _ : _) = firstMissing xs (lotsOfNums B16)
153 ic' xs@(B32 _ : _) = firstMissing xs (lotsOfNums B32)
154 ic' xs@(B64 _ : _) = firstMissing xs (lotsOfNums B64)
155 ic' xs@(Ch _ : _) = firstMissing xs lotsOfChars
156 ic' xs@(Str _ : _) = firstMissing xs lotsOfStrings
158 -- The rest are types with only one case
161 firstMissing cs (x : xs) | x `elem` cs = firstMissing cs xs
164 lotsOfNums t = map t [0..]
165 lotsOfChars = map Ch ['a'..]
166 lotsOfStrings = map Str (map (("some string " ++).show) [1..])
168 conForm (PApp _ (PRef fc n) _) = isConName n (tt_ctxt i)
169 conForm (PRef fc n) = isConName n (tt_ctxt i)
172 nubMap f acc [] = acc
173 nubMap f acc (x : xs) = nubMap f (fnub' acc (f x)) xs
175 otherPats :: PTerm -> [PTerm]
176 otherPats o@(PRef fc n) = ops fc n [] o
177 otherPats o@(PApp _ (PRef fc n) xs) = ops fc n xs o
178 otherPats o@(PPair fc l r)
180 ([pimp (UN "A") Placeholder, pimp (UN "B") Placeholder] ++
182 otherPats o@(PDPair fc t _ v)
183 = ops fc (UN "Ex_intro")
184 ([pimp (UN "a") Placeholder, pimp (UN "P") Placeholder] ++
186 otherPats o@(PConstant c) = return o
187 otherPats arg = return Placeholder
190 | (TyDecl c@(DCon _ arity) ty : _) <- lookupDef n (tt_ctxt i)
191 = do let force = getForceable i n -- no need to generate forceable positions
192 let xs = dropForce force xs_in 0
193 xs' <- mapM otherPats (map getTm xs)
194 let p = resugar (PApp fc (PRef fc n) (zipWith upd xs' xs))
195 let tyn = getTy n (tt_ctxt i)
196 case lookupCtxt tyn (idris_datatypes i) of
197 (TI ns _ _ : _) -> p : map (mkPat fc) (ns \\ [n])
199 ops fc n arg o = return Placeholder
201 -- put it back to its original form
202 resugar (PApp _ (PRef fc (UN "Ex_intro")) [_,_,t,v])
203 = PDPair fc (getTm t) Placeholder (getTm v)
204 resugar (PApp _ (PRef fc n) [_,_,l,r])
206 = PPair fc (getTm l) (getTm r)
209 getForceable i n = case lookupCtxt n (idris_optimisation i) of
213 dropForce force (x : xs) i | i `elem` force
214 = upd Placeholder x : dropForce force xs (i + 1)
215 dropForce force (x : xs) i = x : dropForce force xs (i + 1)
216 dropForce _ [] _ = []
219 getTy n ctxt = case lookupTy n ctxt of
220 (t : _) -> case unApply (getRetTy t) of
221 (P _ tyn _, _) -> tyn
222 x -> error $ "Can't happen getTy 1 " ++ show (n, x)
223 _ -> error "Can't happen getTy 2"
225 mkPat fc x = case lookupCtxt x (idris_implicits i) of
227 -> PApp fc (PRef fc x) (map (upd Placeholder) pargs)
228 _ -> error "Can't happen - genAll"
230upd p' p = p { getTm = p' }
232-- Check if, in a given type n, the constructor cn : ty is strictly positive,
233-- and update the context accordingly
235checkPositive :: Name -> (Name, Type) -> Idris ()
236checkPositive n (cn, ty)
239 let tot = if p then Total (args ty) else Partial NotPositive
240 let ctxt' = setTotal cn tot (tt_ctxt i)
241 putIState (i { tt_ctxt = ctxt' })
242 logLvl 5 $ "Constructor " ++ show cn ++ " is " ++ show tot
243 addIBC (IBCTotal cn tot)
245 args t = [0..length (getArgTys t)-1]
247 cp (Bind n (Pi aty) sc) = posArg aty && cp sc
250 posArg (Bind _ (Pi nty) sc)
251 | (P _ n' _, args) <- unApply nty
252 = n /= n' && posArg sc
255calcProd :: IState -> FC -> Name -> [([Name], Term, Term)] -> Idris Totality
256calcProd i fc topn pats
259 -- every application of n must be in an argument of a coinductive
260 -- constructor, in every function reachable from here in the
262 cp n pats done = do patsprod <- mapM (prodRec n done) pats
264 then return Productive
265 else return (Partial NotProductive)
267 prodRec :: Name -> [Name] -> ([Name], Term, Term) -> Idris Bool
268 prodRec n done _ | n `elem` done = return True
269 prodRec n done (_, _, tm) = prod n done False tm
271 prod :: Name -> [Name] -> Bool -> Term -> Idris Bool
272 prod n done ok ap@(App _ _)
273 | (P _ (UN "lazy") _, [_, arg]) <- unApply ap = prod n done ok arg
274 | (P nt f _, args) <- unApply ap
275 = do recOK <- checkProdRec (n:done) f
277 let [ty] = lookupTy f ctxt -- must exist!
278 let co = cotype nt f ty in
279 if (not recOK) then return False else
281 then do argsprod <- mapM (prod n done co) args
282 return (and (ok : argsprod) )
283 else do argsprod <- mapM (prod n done co) args
284 return (and argsprod)
285 prod n done ok (App f a) = liftM2 (&&) (prod n done False f)
286 (prod n done False a)
287 prod n done ok (Bind _ (Let t v) sc)
288 = liftM2 (&&) (prod n done False v) (prod n done False v)
289 prod n done ok (Bind _ b sc) = prod n done ok sc
290 prod n done ok t = return True
292 checkProdRec :: [Name] -> Name -> Idris Bool
294 = case lookupCtxt f (idris_patdefs i) of
295 [(def, _)] -> do ok <- mapM (prodRec f done) def
297 _ -> return True -- defined elsewhere, can't call topn
299 cotype (DCon _ _) n ty
300 | (P _ t _, _) <- unApply (getRetTy ty)
301 = case lookupCtxt t (idris_datatypes i) of
302 [TI _ True _] -> True
304 cotype nt n ty = False
306calcTotality :: [Name] -> FC -> Name -> [([Name], Term, Term)]
308calcTotality path fc n pats
310 let opts = case lookupCtxt n (idris_flags i) of
313 case mapMaybe (checkLHS i) (map (\ (_, l, r) -> l) pats) of
314 (failure : _) -> return failure
315 _ -> if (Coinductive `elem` opts)
316 then calcProd i fc n pats
317 else checkSizeChange n
319 checkLHS i (P _ fn _)
320 = case lookupTotal fn (tt_ctxt i) of
321 [Partial _] -> return (Partial (Other [fn]))
323 checkLHS i (App f a) = mplus (checkLHS i f) (checkLHS i a)
324 checkLHS _ _ = Nothing
326checkTotality :: [Name] -> FC -> Name -> Idris Totality
327checkTotality path fc n
328 | n `elem` path = return (Partial (Mutual (n : path)))
331 updateContext (simplifyCasedef n)
334 let opts = case lookupCtxt n (idris_flags i) of
339 case lookupDef n ctxt of
340 [CaseOp _ _ _ pats _] ->
341 do t' <- if AssertTotal `elem` opts
342 then return $ Total []
343 else calcTotality path fc n pats
345 addIBC (IBCTotal n t')
346 -- if it's not total, it can't reduce, to keep
347 -- typechecking decidable
349-- FIXME: Put this back when we can handle mutually recursive things
351 do setAccessibility n Frozen
352 addIBC (IBCAccess n Frozen)
353 logLvl 5 $ "HIDDEN: "
357 _ -> return $ Total []
361 Productive -> return t'
362 e -> do w <- cmdOptType WarnPartial
363 if TotalFn `elem` opts
364 then totalityError t'
365 else do when (w && not (PartialFn `elem` opts)) $
369 totalityError t = tclift $ tfail (At fc (Msg (show n ++ " is " ++ show t)))
373 case lookupDef n (tt_ctxt i) of
375 iputStrLn $ show fc ++ ":Warning - " ++ show n ++ " is " ++ show t
377-- let cg = lookupCtxtName Nothing n (idris_callgraph i)
378-- iputStrLn (show cg)
381checkDeclTotality :: (FC, Name) -> Idris Totality
382checkDeclTotality (fc, n)
383 = do logLvl 2 $ "Checking " ++ show n ++ " for totality"
385-- logLvl 2 $ "Built SCG"
386 checkTotality [] fc n
388-- Calculate the size change graph for this definition
390-- SCG for a function f consists of a list of:
391-- (g, [(a1, sizechange1), (a2, sizechange2), ..., (an, sizechangen)])
393-- where g is a function called
394-- a1 ... an are the arguments of f in positions 1..n of g
395-- sizechange1 ... sizechange2 is how their size has changed wrt the input
397-- Nothing, if the argument is unrelated to the input
399buildSCG :: (FC, Name) -> Idris ()
402 case lookupCtxt n (idris_callgraph ist) of
403 [cg] -> case lookupDef n (tt_ctxt ist) of
404 [CaseOp _ _ pats _ cd] ->
405 let (args, sc) = cases_totcheck cd in
406 do logLvl 2 $ "Building SCG for " ++ show n ++ " from\n"
407 ++ show pats ++ "\n" ++ show sc
408 let newscg = buildSCG' ist (rights pats) args
409 logLvl 5 $ show newscg
410 addToCG n ( cg { scg = newscg } )
411 [] -> logLvl 5 $ "Could not build SCG for " ++ show n ++ "\n"
412 x -> error $ "buildSCG: " ++ show (n, x)
414buildSCG' :: IState -> [(Term, Term)] -> [Name] -> [SCGEntry]
415buildSCG' ist pats args = nub $ concatMap scgPat pats where
416 scgPat (lhs, rhs) = let (f, pargs) = unApply (dePat lhs) in
417 findCalls (dePat rhs) (patvars lhs) pargs
419 findCalls ap@(App f a) pvs pargs
420 | (P _ (UN "lazy") _, [_, arg]) <- unApply ap
421 = findCalls arg pvs pargs
422 | (P _ n _, args) <- unApply ap
423 = mkChange n args pargs ++
424 concatMap (\x -> findCalls x pvs pargs) args
425 findCalls (App f a) pvs pargs
426 = findCalls f pvs pargs ++ findCalls a pvs pargs
427 findCalls (Bind n (Let t v) e) pvs pargs
428 = findCalls v pvs pargs ++ findCalls e (n : pvs) pargs
429 findCalls (Bind n _ e) pvs pargs
430 = findCalls e (n : pvs) pargs
431 findCalls (P _ f _ ) pvs pargs
432 | not (f `elem` pvs) = [(f, [])]
435 mkChange n args pargs = [(n, sizes args)]
438 sizes (a : as) = checkSize a pargs 0 : sizes as
440 -- find which argument in pargs <a> is smaller than, if any
441 checkSize a (p : ps) i
442 | a == p = Just (i, Same)
443 | smaller Nothing a (p, Nothing) = Just (i, Smaller)
444 | otherwise = checkSize a ps (i + 1)
445 checkSize a [] i = Nothing
447 -- the smaller thing we find must be the same type as <a>, and
448 -- not be coinductive - so carry the type of the constructor we've
451 smaller (Just tyn) a (t, Just tyt)
452 | a == t = isInductive (fst (unApply (getRetTy tyn)))
453 (fst (unApply (getRetTy tyt)))
454 smaller ty a (ap@(App f s), _)
455 | (P (DCon _ _) n _, args) <- unApply ap
456 = let tyn = getType n in
457 any (smaller (ty `mplus` Just tyn) a)
458 (zip args (map toJust (getArgTys tyn)))
459 -- check higher order recursive arguments
460 smaller ty (App f s) a = smaller ty f a
461 smaller _ _ _ = False
463 toJust (n, t) = Just t
465 getType n = case lookupTy n (tt_ctxt ist) of
466 [ty] -> ty -- must exist
468 isInductive (P _ nty _) (P _ nty' _) =
469 let co = case lookupCtxt nty (idris_datatypes ist) of
472 nty == nty' && not co
473 isInductive _ _ = False
475-- getTypeFam t | (P _ n _, _) <- unApply t
477 dePat (Bind x (PVar ty) sc) = dePat (instantiate (P Bound x ty) sc)
480 patvars (Bind x (PVar _) sc) = x : patvars sc
484buildSCG' :: IState -> SC -> [Name] -> [SCGEntry]
485buildSCG' ist sc args = -- trace ("Building SCG for " ++ show sc) $
486 nub $ scg sc (zip args args)
487 (zip args (zip args (repeat Same)))
489 scg :: SC -> [(Name, Name)] -> -- local var, originating top level var
490 [(Name, (Name, SizeChange))] -> -- orig to new, and relationship
492 scg (Case x alts) vars szs
493 = let x' = findTL x vars in
494 concatMap (scgAlt x' vars szs) alts
497 | Just x' <- lookup x vars
498 = if x' `elem` args then x'
502 scg (STerm tm) vars szs = scgTerm tm vars szs
505 -- how the arguments relate - either Smaller or Unknown
506 argRels :: Name -> [(Name, SizeChange)]
507 argRels n = let ctxt = tt_ctxt ist
508 [ty] = lookupTy n ctxt -- must exist!
509 P _ nty _ = fst (unApply (getRetTy ty))
510 co = case lookupCtxt nty (idris_datatypes ist) of
513 args = map snd (getArgTys ty) in
514 map (getRel co nty) (map (fst . unApply . getRetTy) args)
516 getRel True _ _ = (n, Unknown) -- coinductive
517 getRel _ ty (P _ n' _) | n' == ty = (n, Smaller)
518 getRel _ ty t = (n, Unknown)
520 scgAlt x vars szs (ConCase n _ args sc)
521 -- all args smaller than top variable of x in sc
522 -- (as long as they are in the same type family, and it's
524 | Just tvar <- lookup x vars
525 = let arel = argRels n
526 szs' = zipWith (\arg (_,t) -> (arg, (x, t))) args arel
528 vars' = nub (zip args (repeat tvar) ++ vars) in
530 | otherwise = scg sc vars szs
531 scgAlt x vars szs (ConstCase _ sc) = scg sc vars szs
532 scgAlt x vars szs (DefaultCase sc) = scg sc vars szs
534 scgTerm f@(App _ _) vars szs
535 | (P _ (UN "lazy") _, [_, arg]) <- unApply f
536 = scgTerm arg vars szs
537 | (P _ fn _, args) <- unApply f
538 = let rest = concatMap (\x -> scgTerm x vars szs) args in
539 case lookup fn vars of
541 Nothing -> nub $ (fn, map (mkChange szs) args) : rest
542 scgTerm (App f a) vars szs
543 = scgTerm f vars szs ++ scgTerm a vars szs
544 scgTerm (Bind n (Let t v) e) vars szs
545 = scgTerm v vars szs ++ scgTerm e vars szs
546 scgTerm (Bind n _ e) vars szs
547 = scgTerm e (nub ((n, n) : vars)) szs
548 scgTerm (P _ fn _) vars szs
549 = case lookup fn vars of
551 Nothing -> [(fn, [])]
554 mkChange :: [(Name, (Name, SizeChange))] -> Term
555 -> Maybe (Int, SizeChange)
557 | (P _ (UN "lazy") _, [_, arg]) <- unApply tm = mkChange szs arg
558 | (P _ n ty, _) <- unApply tm -- get higher order args too
559 = do sc <- lookup n szs
561 (_, Unknown) -> Nothing
562 (o, sc) -> do i <- getArgPos 0 o args
564 mkChange _ _ = Nothing
566 getArgPos :: Int -> Name -> [Name] -> Maybe Int
567 getArgPos i n [] = Nothing
568 getArgPos i n (x : xs) | n == x = Just i
569 | otherwise = getArgPos (i + 1) n xs
572checkSizeChange :: Name -> Idris Totality
573checkSizeChange n = do
575 case lookupCtxt n (idris_callgraph ist) of
576 [cg] -> do let ms = mkMultiPaths ist [] (scg cg)
577 logLvl 5 ("Multipath for " ++ show n ++ ":\n" ++
578 "from " ++ show (scg cg) ++ "\n" ++
579 show (length ms) ++ "\n" ++
580 showSep "\n" (map show ms))
582 -- every multipath must have an infinitely descending
583 -- thread, then the function terminates
584 -- also need to checks functions called are all total
585 -- (Unchecked is okay as we'll spot problems here)
586 let tot = map (checkMP ist (length (argsdef cg))) ms
587 logLvl 4 $ "Generated " ++ show (length tot) ++ " paths"
588 logLvl 6 $ "Paths for " ++ show n ++ " yield " ++ (show tot)
589 return (noPartial tot)
590 [] -> do logLvl 5 $ "No paths for " ++ show n
593type MultiPath = [SCGEntry]
595mkMultiPaths :: IState -> MultiPath -> [SCGEntry] -> [MultiPath]
596mkMultiPaths ist path [] = [reverse path]
597mkMultiPaths ist path cg
598 = concat (map extend cg)
599 where extend (nextf, args)
600 | (nextf, args) `elem` path = [ reverse ((nextf, args) : path) ]
601 | [Unchecked] <- lookupTotal nextf (tt_ctxt ist)
602 = case lookupCtxt nextf (idris_callgraph ist) of
603 [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
604 _ -> [ reverse ((nextf, args) : path) ]
605 | otherwise = [ reverse ((nextf, args) : path) ]
607-- do (nextf, args) <- cg
608-- if ((nextf, args) `elem` path)
609-- then return (reverse ((nextf, args) : path))
610-- else case lookupCtxt nextf (idris_callgraph ist) of
611-- [ncg] -> mkMultiPaths ist ((nextf, args) : path) (scg ncg)
612-- _ -> return (reverse ((nextf, args) : path))
614-- If any route along the multipath leads to infinite descent, we're fine.
615-- Try a route beginning with every argument.
616-- If we reach a point we've been to before, but with a smaller value,
617-- that means there is an infinitely descending path from that argument.
619checkMP :: IState -> Int -> MultiPath -> Totality
620checkMP ist i mp = if i > 0
621 then collapse (map (tryPath 0 [] mp) [0..i-1])
622 else tryPath 0 [] mp 0
624 tryPath' d path mp arg
625 = let res = tryPath d path mp arg in
626 trace (show mp ++ "\n" ++ show arg ++ " " ++ show res) res
628 tryPath :: Int -> [(SCGEntry, Int)] -> MultiPath -> Int -> Totality
629 tryPath desc path [] _ = Total []
630-- tryPath desc path ((UN "believe_me", _) : _) arg
631-- = Partial BelieveMe
632 -- if we get to a constructor, it's fine as long as it's strictly positive
633 tryPath desc path ((f, _) :es) arg
634 | [TyDecl (DCon _ _) _] <- lookupDef f (tt_ctxt ist)
635 = case lookupTotal f (tt_ctxt ist) of
636 [Total _] -> Unchecked -- okay so far
637 [Partial _] -> Partial (Other [f])
639 | [TyDecl (TCon _ _) _] <- lookupDef f (tt_ctxt ist)
641 tryPath desc path (e@(f, args) : es) arg
642 | e `elem` es && allNothing args = Partial (Mutual [f])
643 tryPath desc path (e@(f, nextargs) : es) arg
644 | Just d <- lookup e path
646 then -- trace ("Descent " ++ show (desc - d) ++ " "
647 -- ++ show (path, e)) $
649 else Partial (Mutual (map (fst . fst) path ++ [f]))
650 | [Unchecked] <- lookupTotal f (tt_ctxt ist) =
651 let argspos = collapseNothing (zip nextargs [0..]) in
652 collapse' Unchecked $
653 do (a, pos) <- argspos
655 Nothing -> -- don't know, but if the
656 -- rest definitely terminates without
657 -- any cycles with route so far,
658 -- then we might yet be total
659 case collapse (map (tryPath (-10000) ((e, 0):path) es)
660 [0..length nextargs - 1]) of
661 Total _ -> return Unchecked
663 Just (nextarg, sc) ->
664 if nextarg == arg then
666 Same -> return $ tryPath desc ((e, desc) : path)
668 Smaller -> return $ tryPath (desc+1)
672 _ -> trace ("Shouldn't happen " ++ show e) $
673 return (Partial Itself)
674 else return Unchecked
675 | [Total a] <- lookupTotal f (tt_ctxt ist) = Total a
676 | [Partial _] <- lookupTotal f (tt_ctxt ist) = Partial (Other [f])
677 | otherwise = Unchecked
679allNothing xs = null (collapseNothing (zip xs [0..]))
681collapseNothing ((Nothing, _) : xs)
682 = filter (\ (x, _) -> case x of
685collapseNothing (x : xs) = x : collapseNothing xs
686collapseNothing [] = []
688noPartial (Partial p : xs) = Partial p
689noPartial (_ : xs) = noPartial xs
690noPartial [] = Total []
692collapse xs = collapse' Unchecked xs
693collapse' def (Total r : xs) = Total r
694collapse' def (Unchecked : xs) = collapse' def xs
695collapse' def (d : xs) = collapse' d xs
696-- collapse' Unchecked [] = Total []
697collapse' def [] = def
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list