<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<blockquote type="cite"
cite="mid:CADEOade=9LDSUPbf8HjvYd28t=h_r1PT+qt0PwEa76PkCMQ4kw@mail.gmail.com">
<pre class="moz-quote-pre" wrap="">i have this in a Monad IO:
forM_ fltrdNamesBDs $ \(name,bdSidonie,bdWDS) ->
if (bdWDS /= bdSidonie)
then
putStrLn $ name ++ " " ++ (show (bdSidonie :: Maybe Float))
++ " " ++ show (bdWDS :: Maybe Float) ++ " " ++ show (bdWDS == bdSidonie)
else
putStr ""
is there a way to remove the silly putStr "" that output an empty string, i
tried with when.... but as when return Nothing in case of False it fails to
compile
</pre>
</blockquote>
<p><br>
</p>
<p>I don't see the problem with <tt>when</tt>? This (in the
expanded version) doesn't work?<br>
</p>
<pre> forM_ fltrdNamesBDs $ \(name,bdSidonie,bdWDS) -> when (bdWDS /= bdSidonie) $ showStuff name bdSidonie bdWDS</pre>
<p>As an extra remark, whenever I want to output a whole bunch of
stuff in a row like this, I like to refactor into a <tt>concat</tt>,
just to make the code more readable. If I can factor out the
types, all the better:<br>
</p>
<pre> where
showStuff :: String -> Maybe Float -> Maybe Float -> IO ()
showStuff name bdSidonie bdWDS = putStrLn $ concat [name," ",show bdSidonie," ",show bdWDS," False"]</pre>
<p>Or even</p>
<pre> showStuff :: String -> Maybe Float -> Maybe Float -> IO ()
showStuff name bdSidonie bdWDS = putStrLn $ Data.List.intercalate " " [name,show bdSidonie,show bdWDS,show False]</pre>
<p><br>
</p>
<p>Cheers.<br>
</p>
</body>
</html>