tag:blogger.com,1999:blog-7094652.post4165368562608175375..comments2024-03-23T14:36:09.980+00:00Comments on Neil Mitchell's Blog (Haskell etc): Explaining Haskell IO without MonadsNeil Mitchellhttp://www.blogger.com/profile/13084722756124486154noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-7094652.post-39786396198793464352012-05-28T03:00:33.206+01:002012-05-28T03:00:33.206+01:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/13061624169044043923noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-49001725376884898682012-05-28T02:59:51.310+01:002012-05-28T02:59:51.310+01:00Thanks a lot. this is the best post i have read in...Thanks a lot. this is the best post i have read in past 2 days about how to pass string from readFile to other functions without worrying about "IO String".Anonymoushttps://www.blogger.com/profile/13061624169044043923noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-52146997612579792542010-04-08T21:15:31.519+01:002010-04-08T21:15:31.519+01:00Beginners (and me) prefer if
Sorry to get off topi...<em>Beginners (and me) prefer if</em><br />Sorry to get off topic… I think that a programmer should get used to "case … of" at the very beginning. In Haskell "case … of" is primitive construction and in C, Pascal and other imperative languages "if" is primitive construction. Invariable use of "if" may lead to the wrong belief that "if" is special in Haskell. Personally I always fall to core Haskell when rules of syntactic sugar is not clear to me or seems tricky or complex.beroalhttps://www.blogger.com/profile/13229768366613602827noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-33932295231342804242010-04-08T06:06:47.225+01:002010-04-08T06:06:47.225+01:00Alexey: I'll try and make that revision in a f...Alexey: I'll try and make that revision in a future version.<br /><br />beroal: Beginners (and me) prefer if, although case would neatly solve the indentation problem. However, GHC is also going to solve the indentation problem shortly, so less of an issue. Putting when in optional IO is a good idea, but you really need IO as a value first. I'll think about how to include when.<br /><br />seriousken: It was icey, I slipped on the ice, i fell over and hit my elbow. Nothing too serious, but a good chunk of flesh missing.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-35020614799957123902010-04-07T23:24:29.295+01:002010-04-07T23:24:29.295+01:00Now you have to tell the Hospital story.Now you have to tell the Hospital story.Unknownhttps://www.blogger.com/profile/01607960773097642101noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-13545979747830851042010-01-10T19:24:16.874+00:002010-01-10T19:24:16.874+00:00The only subtle point is that the else must be ind...<i>The only subtle point is that the else must be indented by one more space than the if. This caveat is widely considered to be a bug in the definition of Haskell, but for the moment, the extra space before the else is required.</i><br />"case … of" is more general and meshes nicely with identations. :)<br /><br />In the chapter "Optional IO" it's natural to consider Control.Monad.when .beroalhttps://www.blogger.com/profile/13229768366613602827noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-55240194204606830252010-01-10T13:04:04.547+00:002010-01-10T13:04:04.547+00:00In "Action List", I think it would be go...In "Action List", I think it would be good to say explicitly how the types of xI and exprI are related.Alexey Romanovhttps://www.blogger.com/profile/04414745317669007614noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-48064830578529029882010-01-08T16:39:33.342+00:002010-01-08T16:39:33.342+00:00Eric: I hereby license this post under the "C...Eric: I hereby license this post under the "Creative Commons Attribution/Share-Alike license"<br /><br />I'm not going to have time to merge it in to the wiki book, but you're welcome to steal what you want. Looking at the wikibook it's a lot longer, I like my tutorials short and punchy, but not everyone has the same preferences.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-21137553219428532602010-01-04T10:39:33.979+00:002010-01-04T10:39:33.979+00:00Nice, Neil. It's worth thinking about merging...Nice, Neil. It's worth thinking about merging this into the wikibook, or barring that, granting something at least as permissive as the Creative Commons Attribution/Share-Alike license.<br /><br />The wikibook <a href="http://en.wikibooks.org/wiki/Haskell/Simple_input_and_output" rel="nofollow">chapter on IO</a> tries to achieve the same effect, that is, focus on getting people to be able to do IO without worrying about monads. But it is much clumsier. I basically took YAHT and tried to refocus it on practice and threw in a lot of rambling nonsense along the way.<br /><br />Your post, on the other hand, a nice catalogue of patterns, is quite usable.<br /><br />Also, it would be nice to see a real "Haskell IO without Monads" post one day :-)koweyhttps://www.blogger.com/profile/11175806459477851520noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-46678565520773520302010-01-03T17:24:42.059+00:002010-01-03T17:24:42.059+00:00Maciej: That rule is listed in the section "P...Maciej: That rule is listed in the section "Pattern Matching" - it makes it slightly too confusing to introduce it at the same time as the other rules, as it's not so interesting usually.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-52604828293590152012010-01-03T17:08:41.817+00:002010-01-03T17:08:41.817+00:00Next simplifictaion rule:
If there is only one lin...Next simplifictaion rule:<br />If there is only one line do can be ommited.<br /><br />I.e. do action -> actionAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-14830178358878177602010-01-03T17:06:37.597+00:002010-01-03T17:06:37.597+00:00Thank you for your immediate reply!
Your explanati...Thank you for your immediate reply!<br />Your explanation is clear and concise.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-87806006166995197482010-01-03T16:35:51.122+00:002010-01-03T16:35:51.122+00:00okagawa: My definition of sequence_ is:
[IO ()] -...okagawa: My definition of sequence_ is:<br /><br />[IO ()] -> IO ()<br /><br />To get to the standard definition you make two changes.<br /><br />1) sequence_ works on any monad, so you can change from IO to m, where m is a monad.<br /><br />Monad m => [m ()] -> m ()<br /><br />2) sequence_ takes a list of actions, and runs them. But the actions could return results, they just get discarded. So actually, we could allow any type of actions.<br /><br />Monad m => [m a] -> m ()<br /><br />Another way to see it is that my sequence_ is just the standard sequence with m set to IO, and a set to ().Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-17209088252502526702010-01-03T16:18:04.457+00:002010-01-03T16:18:04.457+00:00First of all, I think this is a good tutorial on H...First of all, I think this is a good tutorial on Haskell IO.<br />As I just finished reading "Programming in Haskell", this article was greate to me.<br /><br />I'm afraid this is beyond the scope of this tutorial, let me ask a question on the type signature of seqence_.<br />In your article, type signature of sequence_ was "[IO ()] -> IO ()". I tried to change it to generic form, and found that it has to be "(Monad m) => [m a] -> m ()" as it was in Prelude's sequence_.<br />It looks like that "m a" is the generic form of "IO ()" as the argument type and "m ()" is the generic form of "IO ()" as the return type.<br />My confusions are why they has to be different and what the meaning is.<br /><br />If possible, please let me know about it, or pointer to the relevant literature.<br /><br />Thanks,Anonymousnoreply@blogger.com