summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/strun003.hs
blob: 90594a5c40f09ae517fe43691c8199f47f09c47e (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.Op.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