Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.haskell > #509
| From | Mark Carroll <mtbc@bcs.org> |
|---|---|
| Newsgroups | comp.lang.haskell |
| Subject | Re: Get mapM to be lazy for IO |
| Date | 2018-12-11 13:36 +0000 |
| Organization | none |
| Message-ID | <87bm5s4249.fsf@ixod.org> (permalink) |
| References | <24548724-4bdd-402d-8a76-1403b7e87169@googlegroups.com> |
On 11 Dec 2018, kfjwheeler wrote: > I'm kind of a beginner when it comes to Haskell. Specifically with > regards to IO. You're making a promising start! (snip) > I'm getting close, but it's still asking for input after I enter > "done". I can't seem to get mapM to be lazy in the way I want. You're doing the three IO actions in sequence then selecting from their results. Broadly, with IO you don't get to skip stuff after the >>= just by not consuming the result. So, you need to move the check of the input value amid the sequence itself, only do further IO actions if necessary. You could try rolling that yourself (do another >>= only if necessary) or use the help of something like unfoldM, we'd be happy to help you with either. -- Mark
Back to comp.lang.haskell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Get mapM to be lazy for IO kfjwheeler@gmail.com - 2018-12-11 05:19 -0800
Re: Get mapM to be lazy for IO Mark Carroll <mtbc@bcs.org> - 2018-12-11 13:36 +0000
Re: Get mapM to be lazy for IO Kaylen Wheeler <kfjwheeler@gmail.com> - 2018-12-12 17:52 -0800
Re: Get mapM to be lazy for IO Paul Rubin <no.email@nospam.invalid> - 2018-12-12 19:29 -0800
Re: Get mapM to be lazy for IO Kaylen Wheeler <kfjwheeler@gmail.com> - 2018-12-12 18:21 -0800
Re: Get mapM to be lazy for IO Paul Rubin <no.email@nospam.invalid> - 2018-12-12 19:31 -0800
Re: Get mapM to be lazy for IO Barry Fishman <barry@ecubist.org> - 2018-12-13 09:52 -0500
Re: Get mapM to be lazy for IO Barry Fishman <barry@ecubist.org> - 2018-12-13 10:21 -0500
Re: Get mapM to be lazy for IO Barry Fishman <barry@ecubist.org> - 2018-12-13 10:46 -0500
csiph-web