Commit d93e6355 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Test Trac #3403

parent 43e72382
{-# LANGUAGE BangPatterns #-}
-- See Trac #3403: interaction of pattern match failure and CPR
-- The point is that this should run in constant space, with no
-- stack growth. In GHC 6.10 the tail call optimisation didn't work.
module Main (main) where
import qualified Data.Set as Set
import Data.Set (Set)
data Result = Result !S1 !S2
type S1 = Set ()
type S2 = Set ()
input :: [[(Int, ())]]
input = replicate 1000 (replicate 400 (100, ()))
main :: IO ()
main = do let Result s1 s2 = doAll Set.empty Set.empty () input
print $ Set.size s1
print $ Set.size s2
doAll :: S1 -> S2 -> () -> [[(Int, ())]] -> Result
doAll !s1 !s2 !_ [] = Result s1 s2
doAll !s1 !s2 !unit ([] : xs) = doAll s1 s2 unit xs
doAll !s1 !s2 !unit (((t, _) : x1) : x2 : xs)
| t >= 99999 = doAll s1 s2 unit (x1 : x2 : xs)
doAll !s1 !s2 !unit (((_, ()) : x) : xs)
= doAll s1 s2 unit (x : xs)
......@@ -30,3 +30,5 @@ test('T2756', normal, compile_and_run, [''])
test('T3437', extra_run_opts('+RTS -M10m'), compile_and_run, [''])
test('SeqRule', only_ways(['optc','optasm']), compile_and_run, [''])
test('T3403', normal, compile_and_run, ['-package containers'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment