summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun002.hs
blob: 45fe19fdc96f8fc78371c0db7a964c93de1c2f29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- !!! space leak from overloading !!!
module Main where

-- This program develops a space leak if sfoldl isn't compiled with some
-- care.  See comment about polymorphic recursion in TcMonoBinds.lhs

import System.Environment (getArgs)
import GHC.IOBase

sfoldl :: (a -> Int -> a) -> a -> [Int] -> a
sfoldl f z [] = z
sfoldl f z (x:xs) = _scc_ "sfoldl1" (sfoldl f fzx (fzx `seq` xs))
                  where fzx = _scc_ "fzx" (f z x)


main = IO (\s -> case print (sfoldl (+) (0::Int) [1..200000]) of { IO a -> a s })