<div dir="ltr">Hi, <div><br></div><div>Continuing on from my previous question about powerset using filterM - Thanks to Alexey an<font face="arial, helvetica, sans-serif">d <span style="color:rgb(0,0,0)">Chaddaï. </span></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)">filterM is implemented as below - </span></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)">----</span></font></div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">filterM _ [] = return []
filterM p (x:xs) = do
flg <- p x
ys <- filterM p xs
return (if flg then x:ys else ys)</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)">---</pre></div><div>I still don't quite understand how '<font face="monospace, monospace">flg</font>' being a boolean [] is used in the last <font face="monospace, monospace">'if</font> statement' of implementation because when I try to do the same thing outside in GHCi it fails miserably even though I am casting it to [Int] - </div><div><br></div><div>--</div><div><font face="monospace, monospace">return (if [True, False] then "4" else "3")::[Int]</font><br></div><div>--</div><div><br></div><div>Offtopic : Also if someone can explain how do I reply to individual mails/responses to my queries because I only get a digest on my gmail and there is no way to isolate and reply to individual mails either this list's page or from digest.</div><div><br></div><div>Thanks,</div><div><div><div class="gmail_signature"><div dir="ltr"><font color="#0b5394"><font style="background-color:rgb(255,255,255)"><font size="2" face="georgia, serif">Shishir </font></font></font><br></div></div></div>
</div></div>