summaryrefslogtreecommitdiff
path: root/testsuite/tests/perf/should_run/T4321.hs
blob: b8a0dbc4a144f1e253af48e0901733b9f9c422ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

-- In 6.13 this stack overflowed

module Main (main) where

main :: IO ()
main = let n = 1000000
       in print $ integrate n (1 / fromIntegral n)

integrate :: Int -> Double -> Double
integrate n h = h * (sum (map area [1..n]))
    where area :: Int -> Double
          area i = let x = h * (fromIntegral i - 0.5)
                   in 4 / (1 + x*x)