-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/13/10 09:15 , Jacek Generowicz wrote:
> untilQuit' = (fmap (takeWhile (/= "quit"))) (sequence $ map (>>= report)
> (repeat getLine))
> 
> -- The latter version shows the report, but it doesn't stop at the
> -- appropriate place, so I'm guessing that I'm being bitten by my
> -- ignorance about the interaction of actions and lazyness.

The reason this doesn't stop where you expect it to is that sequence is
effectively strict (that is, it will keep going until the list is
exhausted), but repeat creates an infinite list.  You want the stop
condition between the map-report and the repeat-getLine.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0OWJQACgkQIn7hlCsL25Wb2gCgw3GKF/rBdXL2LIsV5qUVSa1M
ZfEAoL5Vzd9+F7+NDqOAP7s2pyxtmJ0S
=bU/D
-----END PGP SIGNATURE-----

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to