2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[Util]{Highly random utility functions}
7 #include "HsVersions.h"
8 #define IF_NOT_GHC(a) {--}
10 #ifndef __GLASGOW_HASKELL__
19 -- Haskell-version support
20 #ifndef __GLASGOW_HASKELL__
25 SYN_IE(Eager), thenEager, returnEager, mapEager, appEager, runEager,
27 -- general list processing
28 IF_NOT_GHC(forall COMMA exists COMMA)
29 zipEqual, zipWithEqual, zipWith3Equal, zipWith4Equal,
31 mapAndUnzip, mapAndUnzip3,
32 nOfThem, lengthExceeds, isSingleton,
37 assoc, assocUsing, assocDefault, assocDefaultUsing,
40 hasNoDups, equivClasses, runs, removeDups,
43 IF_NOT_GHC(quicksort COMMA stableSortLt COMMA mergesort COMMA)
45 IF_NOT_GHC(mergeSort COMMA) naturalMergeSortLe, -- from Carsten
46 IF_NOT_GHC(naturalMergeSort COMMA mergeSortLe COMMA)
48 -- transitive closures
52 mapAccumL, mapAccumR, mapAccumB,
55 Ord3(..), thenCmp, cmpList,
56 cmpPString, FAST_STRING,
59 IF_NOT_GHC(cfst COMMA applyToPair COMMA applyToFst COMMA)
60 IF_NOT_GHC(applyToSnd COMMA foldPair COMMA)
64 , panic, panic#, pprPanic, pprPanic#, pprError, pprTrace
65 , assertPanic, assertPprPanic
69 CHK_Ubiq() -- debugging consistency check
70 IMPORT_1_3(List(zipWith4))
76 %************************************************************************
78 \subsection{The Eager monad}
80 %************************************************************************
82 The @Eager@ monad is just an encoding of continuation-passing style,
83 used to allow you to express "do this and then that", mainly to avoid
84 space leaks. It's done with a type synonym to save bureaucracy.
87 type Eager ans a = (a -> ans) -> ans
89 runEager :: Eager a a -> a
90 runEager m = m (\x -> x)
92 appEager :: Eager ans a -> (a -> ans) -> ans
93 appEager m cont = m cont
95 thenEager :: Eager ans a -> (a -> Eager ans b) -> Eager ans b
96 thenEager m k cont = m (\r -> k r cont)
98 returnEager :: a -> Eager ans a
99 returnEager v cont = cont v
101 mapEager :: (a -> Eager ans b) -> [a] -> Eager ans [b]
102 mapEager f [] = returnEager []
103 mapEager f (x:xs) = f x `thenEager` \ y ->
104 mapEager f xs `thenEager` \ ys ->
108 %************************************************************************
110 \subsection[Utils-version-support]{Functions to help pre-1.2 versions of (non-Glasgow) Haskell}
112 %************************************************************************
114 This is our own idea:
116 #ifndef __GLASGOW_HASKELL__
117 data TAG_ = LT_ | EQ_ | GT_
119 tagCmp_ :: Ord a => a -> a -> TAG_
120 tagCmp_ a b = if a == b then EQ_ else if a < b then LT_ else GT_
124 %************************************************************************
126 \subsection[Utils-lists]{General list processing}
128 %************************************************************************
130 Quantifiers are not standard in Haskell. The following fill in the gap.
133 forall :: (a -> Bool) -> [a] -> Bool
134 forall pred [] = True
135 forall pred (x:xs) = pred x && forall pred xs
137 exists :: (a -> Bool) -> [a] -> Bool
138 exists pred [] = False
139 exists pred (x:xs) = pred x || exists pred xs
142 A paranoid @zip@ (and some @zipWith@ friends) that checks the lists
143 are of equal length. Alastair Reid thinks this should only happen if
144 DEBUGging on; hey, why not?
147 zipEqual :: String -> [a] -> [b] -> [(a,b)]
148 zipWithEqual :: String -> (a->b->c) -> [a]->[b]->[c]
149 zipWith3Equal :: String -> (a->b->c->d) -> [a]->[b]->[c]->[d]
150 zipWith4Equal :: String -> (a->b->c->d->e) -> [a]->[b]->[c]->[d]->[e]
154 zipWithEqual _ = zipWith
155 zipWith3Equal _ = zipWith3
156 zipWith4Equal _ = zipWith4
158 zipEqual msg [] [] = []
159 zipEqual msg (a:as) (b:bs) = (a,b) : zipEqual msg as bs
160 zipEqual msg as bs = panic ("zipEqual: unequal lists:"++msg)
162 zipWithEqual msg z (a:as) (b:bs)= z a b : zipWithEqual msg z as bs
163 zipWithEqual msg _ [] [] = []
164 zipWithEqual msg _ _ _ = panic ("zipWithEqual: unequal lists:"++msg)
166 zipWith3Equal msg z (a:as) (b:bs) (c:cs)
167 = z a b c : zipWith3Equal msg z as bs cs
168 zipWith3Equal msg _ [] [] [] = []
169 zipWith3Equal msg _ _ _ _ = panic ("zipWith3Equal: unequal lists:"++msg)
171 zipWith4Equal msg z (a:as) (b:bs) (c:cs) (d:ds)
172 = z a b c d : zipWith4Equal msg z as bs cs ds
173 zipWith4Equal msg _ [] [] [] [] = []
174 zipWith4Equal msg _ _ _ _ _ = panic ("zipWith4Equal: unequal lists:"++msg)
179 -- zipLazy is lazy in the second list (observe the ~)
181 zipLazy :: [a] -> [b] -> [(a,b)]
183 zipLazy (x:xs) ~(y:ys) = (x,y) : zipLazy xs ys
187 mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c])
189 mapAndUnzip f [] = ([],[])
193 (rs1, rs2) = mapAndUnzip f xs
197 mapAndUnzip3 :: (a -> (b, c, d)) -> [a] -> ([b], [c], [d])
199 mapAndUnzip3 f [] = ([],[],[])
200 mapAndUnzip3 f (x:xs)
203 (rs1, rs2, rs3) = mapAndUnzip3 f xs
205 (r1:rs1, r2:rs2, r3:rs3)
209 nOfThem :: Int -> a -> [a]
210 nOfThem n thing = take n (repeat thing)
212 lengthExceeds :: [a] -> Int -> Bool
214 [] `lengthExceeds` n = 0 > n
215 (x:xs) `lengthExceeds` n = (1 > n) || (xs `lengthExceeds` (n - 1))
217 isSingleton :: [a] -> Bool
219 isSingleton [x] = True
220 isSingleton _ = False
222 startsWith, endsWith :: String -> String -> Maybe String
224 startsWith [] str = Just str
225 startsWith (c:cs) (s:ss)
226 = if c /= s then Nothing else startsWith cs ss
227 startsWith _ [] = Nothing
230 = case (startsWith (reverse cs) (reverse ss)) of
232 Just rs -> Just (reverse rs)
235 Debugging/specialising versions of \tr{elem} and \tr{notElem}
237 isIn, isn'tIn :: (Eq a) => String -> a -> [a] -> Bool
240 isIn msg x ys = elem__ x ys
241 isn'tIn msg x ys = notElem__ x ys
243 --these are here to be SPECIALIZEd (automagically)
245 elem__ x (y:ys) = x==y || elem__ x ys
247 notElem__ x [] = True
248 notElem__ x (y:ys) = x /= y && notElem__ x ys
256 | i _GE_ ILIT(100) = panic ("Over-long elem in: " ++ msg)
257 | otherwise = x == y || elem (i _ADD_ ILIT(1)) x ys
260 = notElem ILIT(0) x ys
262 notElem i x [] = True
264 | i _GE_ ILIT(100) = panic ("Over-long notElem in: " ++ msg)
265 | otherwise = x /= y && notElem (i _ADD_ ILIT(1)) x ys
271 %************************************************************************
273 \subsection[Utils-assoc]{Association lists}
275 %************************************************************************
277 See also @assocMaybe@ and @mkLookupFun@ in module @Maybes@.
280 assoc :: (Eq a) => String -> [(a, b)] -> a -> b
281 assocDefault :: (Eq a) => b -> [(a, b)] -> a -> b
282 assocUsing :: (a -> a -> Bool) -> String -> [(a, b)] -> a -> b
283 assocDefaultUsing :: (a -> a -> Bool) -> b -> [(a, b)] -> a -> b
285 assocDefaultUsing eq deflt ((k,v) : rest) key
287 | otherwise = assocDefaultUsing eq deflt rest key
289 assocDefaultUsing eq deflt [] key = deflt
291 assoc crash_msg list key = assocDefaultUsing (==) (panic ("Failed in assoc: " ++ crash_msg)) list key
292 assocDefault deflt list key = assocDefaultUsing (==) deflt list key
293 assocUsing eq crash_msg list key = assocDefaultUsing eq (panic ("Failed in assoc: " ++ crash_msg)) list key
296 %************************************************************************
298 \subsection[Utils-dups]{Duplicate-handling}
300 %************************************************************************
303 hasNoDups :: (Eq a) => [a] -> Bool
305 hasNoDups xs = f [] xs
307 f seen_so_far [] = True
308 f seen_so_far (x:xs) = if x `is_elem` seen_so_far then
313 is_elem = isIn "hasNoDups"
317 equivClasses :: (a -> a -> TAG_) -- Comparison
321 equivClasses cmp stuff@[] = []
322 equivClasses cmp stuff@[item] = [stuff]
323 equivClasses cmp items
324 = runs eq (sortLt lt items)
326 eq a b = case cmp a b of { EQ_ -> True; _ -> False }
327 lt a b = case cmp a b of { LT_ -> True; _ -> False }
330 The first cases in @equivClasses@ above are just to cut to the point
333 @runs@ groups a list into a list of lists, each sublist being a run of
334 identical elements of the input list. It is passed a predicate @p@ which
335 tells when two elements are equal.
338 runs :: (a -> a -> Bool) -- Equality
343 runs p (x:xs) = case (span (p x) xs) of
344 (first, rest) -> (x:first) : (runs p rest)
348 removeDups :: (a -> a -> TAG_) -- Comparison function
350 -> ([a], -- List with no duplicates
351 [[a]]) -- List of duplicate groups. One representative from
352 -- each group appears in the first result
354 removeDups cmp [] = ([], [])
355 removeDups cmp [x] = ([x],[])
357 = case (mapAccumR collect_dups [] (equivClasses cmp xs)) of { (dups, xs') ->
360 collect_dups dups_so_far [x] = (dups_so_far, x)
361 collect_dups dups_so_far dups@(x:xs) = (dups:dups_so_far, x)
364 %************************************************************************
366 \subsection[Utils-sorting]{Sorting}
368 %************************************************************************
370 %************************************************************************
372 \subsubsection[Utils-quicksorting]{Quicksorts}
374 %************************************************************************
377 -- tail-recursive, etc., "quicker sort" [as per Meira thesis]
378 quicksort :: (a -> a -> Bool) -- Less-than predicate
380 -> [a] -- Result list in increasing order
383 quicksort lt [x] = [x]
384 quicksort lt (x:xs) = split x [] [] xs
386 split x lo hi [] = quicksort lt lo ++ (x : quicksort lt hi)
387 split x lo hi (y:ys) | y `lt` x = split x (y:lo) hi ys
388 | True = split x lo (y:hi) ys
391 Quicksort variant from Lennart's Haskell-library contribution. This
392 is a {\em stable} sort.
395 stableSortLt = sortLt -- synonym; when we want to highlight stable-ness
397 sortLt :: (a -> a -> Bool) -- Less-than predicate
399 -> [a] -- Result list
401 sortLt lt l = qsort lt l []
403 -- qsort is stable and does not concatenate.
404 qsort :: (a -> a -> Bool) -- Less-than predicate
405 -> [a] -- xs, Input list
406 -> [a] -- r, Concatenate this list to the sorted input list
407 -> [a] -- Result = sort xs ++ r
411 qsort lt (x:xs) r = qpart lt x xs [] [] r
413 -- qpart partitions and sorts the sublists
414 -- rlt contains things less than x,
415 -- rge contains the ones greater than or equal to x.
416 -- Both have equal elements reversed with respect to the original list.
418 qpart lt x [] rlt rge r =
419 -- rlt and rge are in reverse order and must be sorted with an
420 -- anti-stable sorting
421 rqsort lt rlt (x : rqsort lt rge r)
423 qpart lt x (y:ys) rlt rge r =
426 qpart lt x ys (y:rlt) rge r
429 qpart lt x ys rlt (y:rge) r
431 -- rqsort is as qsort but anti-stable, i.e. reverses equal elements
433 rqsort lt [x] r = x:r
434 rqsort lt (x:xs) r = rqpart lt x xs [] [] r
436 rqpart lt x [] rle rgt r =
437 qsort lt rle (x : qsort lt rgt r)
439 rqpart lt x (y:ys) rle rgt r =
442 rqpart lt x ys rle (y:rgt) r
445 rqpart lt x ys (y:rle) rgt r
448 %************************************************************************
450 \subsubsection[Utils-dull-mergesort]{A rather dull mergesort}
452 %************************************************************************
455 mergesort :: (a -> a -> TAG_) -> [a] -> [a]
457 mergesort cmp xs = merge_lists (split_into_runs [] xs)
459 a `le` b = case cmp a b of { LT_ -> True; EQ_ -> True; GT__ -> False }
460 a `ge` b = case cmp a b of { LT_ -> False; EQ_ -> True; GT__ -> True }
462 split_into_runs [] [] = []
463 split_into_runs run [] = [run]
464 split_into_runs [] (x:xs) = split_into_runs [x] xs
465 split_into_runs [r] (x:xs) | x `ge` r = split_into_runs [r,x] xs
466 split_into_runs rl@(r:rs) (x:xs) | x `le` r = split_into_runs (x:rl) xs
467 | True = rl : (split_into_runs [x] xs)
470 merge_lists (x:xs) = merge x (merge_lists xs)
474 merge xl@(x:xs) yl@(y:ys)
476 EQ_ -> x : y : (merge xs ys)
477 LT_ -> x : (merge xs yl)
478 GT__ -> y : (merge xl ys)
481 %************************************************************************
483 \subsubsection[Utils-Carsten-mergesort]{A mergesort from Carsten}
485 %************************************************************************
488 Date: Mon, 3 May 93 20:45:23 +0200
489 From: Carsten Kehler Holst <kehler@cs.chalmers.se>
490 To: partain@dcs.gla.ac.uk
491 Subject: natural merge sort beats quick sort [ and it is prettier ]
493 Here is a piece of Haskell code that I'm rather fond of. See it as an
494 attempt to get rid of the ridiculous quick-sort routine. group is
495 quite useful by itself I think it was John's idea originally though I
496 believe the lazy version is due to me [surprisingly complicated].
497 gamma [used to be called] is called gamma because I got inspired by
498 the Gamma calculus. It is not very close to the calculus but does
499 behave less sequentially than both foldr and foldl. One could imagine
500 a version of gamma that took a unit element as well thereby avoiding
501 the problem with empty lists.
503 I've tried this code against
505 1) insertion sort - as provided by haskell
506 2) the normal implementation of quick sort
507 3) a deforested version of quick sort due to Jan Sparud
508 4) a super-optimized-quick-sort of Lennart's
510 If the list is partially sorted both merge sort and in particular
511 natural merge sort wins. If the list is random [ average length of
512 rising subsequences = approx 2 ] mergesort still wins and natural
513 merge sort is marginally beaten by Lennart's soqs. The space
514 consumption of merge sort is a bit worse than Lennart's quick sort
515 approx a factor of 2. And a lot worse if Sparud's bug-fix [see his
516 fpca article ] isn't used because of group.
523 group :: (a -> a -> Bool) -> [a] -> [[a]]
526 Date: Mon, 12 Feb 1996 15:09:41 +0000
527 From: Andy Gill <andy@dcs.gla.ac.uk>
529 Here is a `better' definition of group.
532 group p (x:xs) = group' xs x x (x :)
534 group' [] _ _ s = [s []]
535 group' (x:xs) x_min x_max s
536 | not (x `p` x_max) = group' xs x_min x (s . (x :))
537 | x `p` x_min = group' xs x x_max ((x :) . s)
538 | otherwise = s [] : group' xs x x (x :)
540 -- This one works forwards *and* backwards, as well as also being
541 -- faster that the one in Util.lhs.
546 let ((h1:t1):tt1) = group p xs
547 (t,tt) = if null xs then ([],[]) else
548 if x `p` h1 then (h1:t1,tt1) else
553 generalMerge :: (a -> a -> Bool) -> [a] -> [a] -> [a]
554 generalMerge p xs [] = xs
555 generalMerge p [] ys = ys
556 generalMerge p (x:xs) (y:ys) | x `p` y = x : generalMerge p xs (y:ys)
557 | otherwise = y : generalMerge p (x:xs) ys
559 -- gamma is now called balancedFold
561 balancedFold :: (a -> a -> a) -> [a] -> a
562 balancedFold f [] = error "can't reduce an empty list using balancedFold"
563 balancedFold f [x] = x
564 balancedFold f l = balancedFold f (balancedFold' f l)
566 balancedFold' :: (a -> a -> a) -> [a] -> [a]
567 balancedFold' f (x:y:xs) = f x y : balancedFold' f xs
568 balancedFold' f xs = xs
570 generalMergeSort p [] = []
571 generalMergeSort p xs = (balancedFold (generalMerge p) . map (: [])) xs
573 generalNaturalMergeSort p [] = []
574 generalNaturalMergeSort p xs = (balancedFold (generalMerge p) . group p) xs
576 mergeSort, naturalMergeSort :: Ord a => [a] -> [a]
578 mergeSort = generalMergeSort (<=)
579 naturalMergeSort = generalNaturalMergeSort (<=)
581 mergeSortLe le = generalMergeSort le
582 naturalMergeSortLe le = generalNaturalMergeSort le
585 %************************************************************************
587 \subsection[Utils-transitive-closure]{Transitive closure}
589 %************************************************************************
591 This algorithm for transitive closure is straightforward, albeit quadratic.
594 transitiveClosure :: (a -> [a]) -- Successor function
595 -> (a -> a -> Bool) -- Equality predicate
597 -> [a] -- The transitive closure
599 transitiveClosure succ eq xs
603 go done (x:xs) | x `is_in` done = go done xs
604 | otherwise = go (x:done) (succ x ++ xs)
607 x `is_in` (y:ys) | eq x y = True
608 | otherwise = x `is_in` ys
611 %************************************************************************
613 \subsection[Utils-accum]{Accumulating}
615 %************************************************************************
617 @mapAccumL@ behaves like a combination
618 of @map@ and @foldl@;
619 it applies a function to each element of a list, passing an accumulating
620 parameter from left to right, and returning a final value of this
621 accumulator together with the new list.
624 mapAccumL :: (acc -> x -> (acc, y)) -- Function of elt of input list
625 -- and accumulator, returning new
626 -- accumulator and elt of result list
627 -> acc -- Initial accumulator
629 -> (acc, [y]) -- Final accumulator and result list
631 mapAccumL f b [] = (b, [])
632 mapAccumL f b (x:xs) = (b'', x':xs') where
634 (b'', xs') = mapAccumL f b' xs
637 @mapAccumR@ does the same, but working from right to left instead. Its type is
638 the same as @mapAccumL@, though.
641 mapAccumR :: (acc -> x -> (acc, y)) -- Function of elt of input list
642 -- and accumulator, returning new
643 -- accumulator and elt of result list
644 -> acc -- Initial accumulator
646 -> (acc, [y]) -- Final accumulator and result list
648 mapAccumR f b [] = (b, [])
649 mapAccumR f b (x:xs) = (b'', x':xs') where
651 (b', xs') = mapAccumR f b xs
654 Here is the bi-directional version, that works from both left and right.
657 mapAccumB :: (accl -> accr -> x -> (accl, accr,y))
658 -- Function of elt of input list
659 -- and accumulator, returning new
660 -- accumulator and elt of result list
661 -> accl -- Initial accumulator from left
662 -> accr -- Initial accumulator from right
664 -> (accl, accr, [y]) -- Final accumulators and result list
666 mapAccumB f a b [] = (a,b,[])
667 mapAccumB f a b (x:xs) = (a'',b'',y:ys)
669 (a',b'',y) = f a b' x
670 (a'',b',ys) = mapAccumB f a' b xs
673 %************************************************************************
675 \subsection[Utils-comparison]{Comparisons}
677 %************************************************************************
679 See also @tagCmp_@ near the versions-compatibility section.
681 The Ord3 class will be subsumed into Ord in Haskell 1.3.
685 cmp :: a -> a -> TAG_
687 thenCmp :: TAG_ -> TAG_ -> TAG_
688 {-# INLINE thenCmp #-}
689 thenCmp EQ_ any = any
690 thenCmp other any = other
692 cmpList :: (a -> a -> TAG_) -> [a] -> [a] -> TAG_
693 -- `cmpList' uses a user-specified comparer
695 cmpList cmp [] [] = EQ_
696 cmpList cmp [] _ = LT_
697 cmpList cmp _ [] = GT_
698 cmpList cmp (a:as) (b:bs)
699 = case cmp a b of { EQ_ -> cmpList cmp as bs; xxx -> xxx }
703 instance Ord3 a => Ord3 [a] where
707 cmp (x:xs) (y:ys) = (x `cmp` y) `thenCmp` (xs `cmp` ys)
709 instance Ord3 a => Ord3 (Maybe a) where
710 cmp Nothing Nothing = EQ_
711 cmp Nothing (Just y) = LT_
712 cmp (Just x) Nothing = GT_
713 cmp (Just x) (Just y) = x `cmp` y
715 instance Ord3 Int where
716 cmp a b | a < b = LT_
722 cmpString :: String -> String -> TAG_
724 cmpString [] [] = EQ_
725 cmpString (x:xs) (y:ys) = if x == y then cmpString xs ys
726 else if x < y then LT_
728 cmpString [] ys = LT_
729 cmpString xs [] = GT_
731 cmpString _ _ = panic# "cmpString"
735 cmpPString :: FAST_STRING -> FAST_STRING -> TAG_
738 = case (tagCmpFS x y) of { _LT -> LT_ ; _EQ -> EQ_ ; _GT -> GT_ }
741 %************************************************************************
743 \subsection[Utils-pairs]{Pairs}
745 %************************************************************************
747 The following are curried versions of @fst@ and @snd@.
750 cfst :: a -> b -> a -- stranal-sem only (Note)
754 The following provide us higher order functions that, when applied
755 to a function, operate on pairs.
758 applyToPair :: ((a -> c),(b -> d)) -> (a,b) -> (c,d)
759 applyToPair (f,g) (x,y) = (f x, g y)
761 applyToFst :: (a -> c) -> (a,b)-> (c,b)
762 applyToFst f (x,y) = (f x,y)
764 applyToSnd :: (b -> d) -> (a,b) -> (a,d)
765 applyToSnd f (x,y) = (x,f y)
767 foldPair :: (a->a->a,b->b->b) -> (a,b) -> [(a,b)] -> (a,b)
768 foldPair fg ab [] = ab
769 foldPair fg@(f,g) ab ((a,b):abs) = (f a u,g b v)
770 where (u,v) = foldPair fg ab abs
774 unzipWith :: (a -> b -> c) -> [(a, b)] -> [c]
775 unzipWith f pairs = map ( \ (a, b) -> f a b ) pairs
778 %************************************************************************
780 \subsection[Utils-errors]{Error handling}
782 %************************************************************************
785 panic x = error ("panic! (the `impossible' happened):\n\t"
787 ++ "Please report it as a compiler bug "
788 ++ "to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\n" )
790 pprPanic heading pretty_msg = panic (heading++ " " ++ (show pretty_msg))
791 pprError heading pretty_msg = error (heading++ " " ++ (show pretty_msg))
792 # if __GLASGOW_HASKELL__ == 201
793 pprTrace heading pretty_msg = GHCbase.trace (heading++" "++(show pretty_msg))
794 # elif __GLASGOW_HASKELL__ >= 202
795 pprTrace heading pretty_msg = GlaExts.trace (heading++" "++(show pretty_msg))
797 pprTrace heading pretty_msg = trace (heading++" "++(show pretty_msg))
800 -- #-versions because panic can't return an unboxed int, and that's
801 -- what TAG_ is with GHC at the moment. Ugh. (Simon)
802 -- No, man -- Too Beautiful! (Will)
804 panic# :: String -> TAG_
805 panic# s = case (panic s) of () -> EQ_
807 pprPanic# heading pretty_msg = panic# (heading++(show pretty_msg))
809 assertPanic :: String -> Int -> a
810 assertPanic file line = panic ("ASSERT failed! file "++file++", line "++show line)
812 assertPprPanic :: String -> Int -> Doc -> a
813 assertPprPanic file line msg
814 = panic (show (sep [hsep[text "ASSERT failed! file",
816 text "line", int line],