4

when i try to compile listing below

import System.Environment(getArgs)
import System.Exit
import Control.Monad(when)
main = do 
    args <- getArgs
    when (length args /= 2) $ do
        putStrLn "Syntax: passwd-al filename uid"
        existFailure

the compiler complaints : The function 'putStrLn' is applied to two arguments. but obviously it takes only one String and existFailure is just another IO action from System.Exit.

how to fix this?

aki
  • 41
  • 2
  • 11
    This error can only happen if the compiler sees the last line as indented further than the previous one. Remove all tabs from your code and use spaces instead, making sure those two last lines line up. Change the settings on your editor so that pressing tab inserts an appropriate number of spaces, or avoid the tab key. – AndrewC Jun 13 '13 at 06:36

1 Answers1

9

I get no such error with putStrLn - it's fine in the code you posted (notice spacing might be different, SO doesn't reproduce tabs and instead only displays indents via spaces, which matters for Haskell).

However, you have existFailure, which I think is really cool but you are probably meaning to use the function exitFailure. Notice the difference between exist and exit.

Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166