testsuite: Assert that testsuite ways are known
[ghc.git] / testsuite / tests / typecheck / should_compile / tc087.hs
1 {-# LANGUAGE RankNTypes #-}
2
3 module ShouldSucceed where
4
5 data SeqView t a = Null
6 | Cons a (t a)
7
8 class PriorityQueue q where
9 empty :: (Ord a) => q a
10 single :: (Ord a) => a -> q a
11 insert :: (Ord a) => a -> q a -> q a
12 meld :: (Ord a) => q a -> q a -> q a
13 splitMin :: (Ord a) => q a -> SeqView q a
14 insert a q = single a `meld` q
15
16 toOrderedList q = case splitMin q of
17 Null -> []
18 Cons a q -> a : toOrderedList q
19
20 insertMany x q = foldr insert q x
21 pqSort q x = toOrderedList (insertMany x q)
22
23 check :: forall q. (PriorityQueue q) => (forall a. Ord a => q a) -> IO ()
24 check empty = do
25 putStr "*** sorting\n"
26 out (pqSort empty [1 .. 99])
27 out (pqSort empty [1.0, 1.1 ..99.9])
28
29 out :: (Eq a, Num a) => [a] -> IO ()
30 out x | sum x == 0 = putStr "ok\n"
31 | otherwise = putStr "ok\n"
32