I have an existing program that takes command line arguments (username, password, date), and then uses the library Network.HTTP.Conduitto send an XML message to the server. Then I parse the results, do some work, and use blaze-html to write to the file.
Everything works like a charm; however, I decided to use haskelineso that the password was not visible. I can create a command-line program that receives user-supplied values โโand displays them, but if I call a function that uses a conduit, it never returns.
Here is the violation code:
main = runInputT defaultSettings loop
where
loop :: InputT IO ()
loop = do
Just username <- getInputLine "WM username: "
Just password <- getPassword (Just '*') "WM password: "
Just date <- getInputLine "Date (YYYYMMDD): "
outputStrLn "querying WM..."
clients <- lift $ getWMClients username password
outputStrLn "successfully retrieved client list from WM..."
let outHeader = renderHeader date username
reportString <- mapM (\x -> createString x clients) cList
lift $ writeFile (date ++ "_report.html") (outHeader ++ concat reportString)
outputStrLn "Done"
GetWMClients function:
getWMClients :: Username -> String -> IO [Client]
getWMClients username password = do
let f = [Size "-1", Skip "0"]
let fs = [Select "id",
Select "status",
Select "last-name",
Select "first-name",
]
let query = WMQuery {transaction=SHARE,service=Query,businessObject=CONT,field=f,fields=fs}
results <- doQuery username (Just password) Nothing (Just query)
rows <- xmlResultsToMaps results
let clients = map makeClient rows
return clients
, " WM...". , http-conduit . , ?
,