@@ -321,6 +321,9 @@ elab ist info pattern tcgen fn tm
321 False -> return failed
321 False -> return failed
322 elabArgs ina failed r ns args
322 elabArgs ina failed r ns args
324+-- For every alternative, look at the function at the head. Automatically resolve
325+-- any nested alternatives where that function is also at the head
324pruneAlt :: [PTerm] -> [PTerm]
327pruneAlt :: [PTerm] -> [PTerm]
325pruneAlt xs = map prune xs
328pruneAlt xs = map prune xs
@@ -328,10 +331,17 @@ pruneAlt xs = map prune xs
328 = PApp fc1 (PRef fc2 f) (fmap (fmap (choose f)) as)
331 = PApp fc1 (PRef fc2 f) (fmap (fmap (choose f)) as)
329 prune t = t
332 prune t = t
331− choose f (PAlternative as) = PAlternative (filter (headIs f) as)
334+ choose f (PAlternative as)
335+ = let as' = fmap (choose f) as
336+ fs = filter (headIs f) as' in
339+ _ -> PAlternative as'
340+ choose f (PApp fc f' as) = PApp fc (choose f f') (fmap (fmap (choose f)) as)
332 choose f t = t
341 choose f t = t
334 headIs f (PApp _ (PRef _ f') _) = f == f'
343 headIs f (PApp _ (PRef _ f') _) = f == f'
344+ headIs f (PApp _ f' _) = headIs f f'
335 headIs f _ = True -- keep if it's not an application
345 headIs f _ = True -- keep if it's not an application
337trivial :: IState -> ElabD ()
347trivial :: IState -> ElabD ()