Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haskell I/O,putStrLn is applied to two arguments [duplicate]

Tags:

haskell

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?

like image 847
aki Avatar asked Jan 13 '23 03:01

aki


1 Answers

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.

like image 196
Thomas M. DuBuisson Avatar answered Jan 29 '23 10:01

Thomas M. DuBuisson