
The original code is: winSSQ count noRed noBlue = do let yesRed = [1..33] \\ noRed let yesBlue = [1..16] \\ noBlue bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1) It works very well. However, as i am used to C style so i want convert it into winSSQ count noRed noBlue = do { let yesRed = [1..33] \\ noRed; let yesBlue = [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } or winSSQ count noRed noBlue = do { yesRed <- [1..33] \\ noRed; yesBlue <- [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } but all fail ! Thomas DuBuisson wrote:
thanks for your quick answer. But I think he actually answered your question. I.e. try it with this extra 'do' statement:
winSSQ count noRed noBlue = do { do let yesRed = [1..33] \\ noRed; let yesBlue = [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); }
In the future please use complete examples that have all variables and import statements. It helps us help you.
Cheers, Thomas _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p2595394... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.