summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/strun003.hs
blob: 893847aa725f6534c772e3f223d8bdbdced19b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- This module should run fine with an empty argument list
-- But it won't if the strictness analyser thinks that 'len' is use
-- strictly, which was the case in GHC 6.0

-- See the io_hack_reqd in GHC.Core.Opt.DmdAnal

module Main where

import System.Environment
import System.Exit

main    = do
            args <- getArgs
            let len = read (head args) :: Int

            (if null args && useLazily len
                then putStrLn "ok" >> exitWith ExitSuccess
                else return () )

            print len

useLazily :: Int -> Bool
useLazily len = ([len,3,4] !! 1) == 3