@@ -120,26 +120,6 @@ genClauses fc n xs given
120 as' <- mkArg as
120 as' <- mkArg as
121 return (a':as')
121 return (a':as')
123−fnub xs = fnub' [] xs
125−fnub' acc (x : xs) | x `qelem` acc = fnub' acc (filter (not.(quickEq x)) xs)
126− | otherwise = fnub' (x : acc) xs
129−-- quick check for constructor equality
130−quickEq :: PTerm -> PTerm -> Bool
131−quickEq (PConstant n) (PConstant n') = n == n'
132−quickEq (PRef _ n) (PRef _ n') = n == n'
133−quickEq (PApp _ t as) (PApp _ t' as')
134− | length as == length as'
135− = quickEq t t' && and (zipWith quickEq (map getTm as) (map getTm as'))
136−quickEq Placeholder Placeholder = True
140−qelem x (y : ys) | x `quickEq` y = True
141− | otherwise = qelem x ys
143-- FIXME: Just look for which one is the deepest, then generate all
123-- FIXME: Just look for which one is the deepest, then generate all
144-- possibilities up to that depth.
124-- possibilities up to that depth.
@@ -244,6 +224,31 @@ genAll i args
244 -> PApp fc (PRef fc x) (map (upd Placeholder) pargs)
224 -> PApp fc (PRef fc x) (map (upd Placeholder) pargs)
245 _ -> error "Can't happen - genAll"
225 _ -> error "Can't happen - genAll"
227+ fnub :: [PTerm] -> [PTerm]
228+ fnub xs = fnub' [] xs
230+ fnub' :: [PTerm] -> [PTerm] -> [PTerm]
231+ fnub' acc (x : xs) | x `qelem` acc = fnub' acc (filter (not.(quickEq x)) xs)
232+ | otherwise = fnub' (x : acc) xs
235+ -- quick check for constructor equality
236+ quickEq :: PTerm -> PTerm -> Bool
237+ quickEq (PConstant n) (PConstant n') = n == n'
238+ quickEq (PRef _ n) (PRef _ n') = n == n'
239+ quickEq (PApp _ t as) (PApp _ t' as')
240+ | length as == length as'
241+ = quickEq t t' && and (zipWith quickEq (map getTm as) (map getTm as'))
242+ quickEq Placeholder Placeholder = True
245+ qelem :: PTerm -> [PTerm] -> Bool
247+ qelem x (y : ys) | x `quickEq` y = True
248+ | otherwise = qelem x ys
251+upd :: t -> PArg' t -> PArg' t
247upd p' p = p { getTm = p' }
252upd p' p = p { getTm = p' }
249-- Check whether function and all descendants cover all cases (partial is
254-- Check whether function and all descendants cover all cases (partial is
@@ -706,8 +711,10 @@ checkMP ist i mp = if i > 0
706 | [Partial _] <- lookupTotal f (tt_ctxt ist) = Partial (Other [f])
711 | [Partial _] <- lookupTotal f (tt_ctxt ist) = Partial (Other [f])
707 | otherwise = Unchecked
712 | otherwise = Unchecked
714+allNothing :: [Maybe a] -> Bool
709allNothing xs = null (collapseNothing (zip xs [0..]))
715allNothing xs = null (collapseNothing (zip xs [0..]))
717+collapseNothing :: [(Maybe a, b)] -> [(Maybe a, b)]
711collapseNothing ((Nothing, _) : xs)
718collapseNothing ((Nothing, _) : xs)
712 = filter (\ (x, _) -> case x of
719 = filter (\ (x, _) -> case x of
713 Nothing -> False
720 Nothing -> False
@@ -715,10 +722,12 @@ collapseNothing ((Nothing, _) : xs)
715collapseNothing (x : xs) = x : collapseNothing xs
722collapseNothing (x : xs) = x : collapseNothing xs
716collapseNothing [] = []
723collapseNothing [] = []
725+noPartial :: [Totality] -> Totality
718noPartial (Partial p : xs) = Partial p
726noPartial (Partial p : xs) = Partial p
719noPartial (_ : xs) = noPartial xs
727noPartial (_ : xs) = noPartial xs
720noPartial [] = Total []
728noPartial [] = Total []
730+collapse :: [Totality] -> Totality
722collapse xs = collapse' Unchecked xs
731collapse xs = collapse' Unchecked xs
723collapse' def (Total r : xs) = Total r
732collapse' def (Total r : xs) = Total r
724collapse' def (Unchecked : xs) = collapse' def xs
733collapse' def (Unchecked : xs) = collapse' def xs