[Haskell-cafe] How to use "bracket" properly ?

Henning Thielemann lemming at henning-thielemann.de
Wed Oct 21 16:57:48 EDT 2009


zaxis schrieb:
> 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);
>     return ()

You might prefer 'withFile' or even better and if possible, write
pickSSQ without IO interaction, just producing a String lazily and write
this using writeFile.



More information about the Haskell-Cafe mailing list