Haskell I / O, putStrLn applies to two arguments

when i try to make a list 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 

compiler complaints: the 'putStrLn' function is applied to two arguments. but it is obvious that only one line is needed and exists. Failure is another IO action from System.Exit.

How to fix it?

+4
source share
1 answer

I do not get such an error with putStrLn - this is good in the code that you posted (the difference between the messages may be different, SO does not play tabs and instead only displays indents through spaces, which matters for Haskell).

However, you have existFailure , which I think is really cool, but you probably mean using the exitFailure function. Note the difference between exist and exit .

+9
source

Source: https://habr.com/ru/post/1485927/


All Articles