summaryrefslogtreecommitdiff
path: root/testsuite/tests/perf/compiler/T11545.hs
blob: d139de70f4edf90acb65db64c8bf1ce3155f680e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
module T11545 where

data A = A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A deriving (Eq)

data QuadTree a = QuadTree !Int [a] (QuadTree a) (QuadTree a) (QuadTree a) (QuadTree a)

foldQuadTree :: (a -> b -> b) -> Int -> b -> QuadTree a -> b
foldQuadTree f maxSize = go
    where
        go z (QuadTree size elems t1 t2 t3 t4)
            | size <= maxSize = foldr f z elems
            | otherwise       = go (go (go (go z t4) t3) t2) t1