tag:blogger.com,1999:blog-1777990983847811806.post225310375580393446..comments2024-03-16T16:29:29.582-07:00Comments on Haskell for all: Basic Haskell ExamplesGabriella Gonzalezhttp://www.blogger.com/profile/01917800488530923694noreply@blogger.comBlogger23125tag:blogger.com,1999:blog-1777990983847811806.post-84991760922217009592021-12-10T15:06:51.272-08:002021-12-10T15:06:51.272-08:00Your programs do lots of IO. I am searching for so...Your programs do lots of IO. I am searching for something simple that illustrates the beautiful, human-readable function composition to total newbies ^^Janekhttps://www.blogger.com/profile/02317840949418525165noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-32212768975493393972017-09-10T11:56:58.612-07:002017-09-10T11:56:58.612-07:00Thnak you, I solved that problem. Another problem ...Thnak you, I solved that problem. Another problem I have is that I have chosen this program for a homework i have, but i don't really understand all the language. Is there a way to simplify the program or can i find some instruction/explanation to the terms used somewhere?Anonymoushttps://www.blogger.com/profile/10879619370406086780noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-22441583782165884472017-09-10T08:51:57.567-07:002017-09-10T08:51:57.567-07:00If you have the Glasgow Haskell compiler (i.e. &qu...If you have the Glasgow Haskell compiler (i.e. "ghc") installed, then you can save the example to a text file called "calendar.hs" and then run the following command at a command line:<br /><br />$ runghc calendar.hs<br /><br />You can find instructions for how to install the Haskell compiler and toolchain here:<br /><br />https://www.haskell.org/downloadsGabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-38617018747626854482017-09-10T05:10:53.912-07:002017-09-10T05:10:53.912-07:00Can you help me understand how to run the calendar...Can you help me understand how to run the calendar example?<br />Anonymoushttps://www.blogger.com/profile/10879619370406086780noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-48532994577803069192015-11-13T20:54:18.499-08:002015-11-13T20:54:18.499-08:00So I like the first simplification of the CSV exam...So I like the first simplification of the CSV example, but I try to avoid imports because the purpose of the exercise is to do as much as possible without any imports or extensions.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-24566715260290602192015-11-09T10:31:24.404-08:002015-11-09T10:31:24.404-08:00Great example ideas! Thanks!
Unfortunately, the c...Great example ideas! Thanks!<br /><br />Unfortunately, the code needs a lot of work before you want to show it to the public as examples of Haskell. Let's take the second problem, tabs-to-commas, as an example. Here's what I would write<br /><br /> tabComma :: Char -> Char<br /> tabComma '\t' = ','<br /> tabComma c = c<br /><br /> main :: IO ()<br /> main = interact (map tabComma)<br /><br />I think this is what your code does? However, it has some problems: you probably want to pay attention to quoting, escaping, etc. Might I humbly suggest that my own Text.SSV approach makes things better here?<br /><br /> import Text.SSV<br /><br /> tsvFormat :: SSVFormat<br /> tsvFormat = csvFormat { ssvFormatSeparator = '\t' }<br /><br /> main :: IO ()<br /> main = interact (showCSV . readSSV tsvFormat)<br /><br />In addition to teaching people about the wonderful resource that is Hackage, this does a pretty reasonable job of actually doing TSV to CSV conversion, and can be further configured if requirements differ just by changing the description records.<br /><br />I'll try to find time to rewrite all the examples and put them on Github somewhere if you like. We should probably start a repo for these anyhow.Bart Masseyhttps://www.blogger.com/profile/10490373418825679148noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-90606140909870379742015-10-25T18:52:35.907-07:002015-10-25T18:52:35.907-07:00OK - that's helpful. Thanks!OK - that's helpful. Thanks!Unknownhttps://www.blogger.com/profile/12274807158417256625noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-76055888353621489912015-10-25T18:42:16.499-07:002015-10-25T18:42:16.499-07:00It's exactly equivalent to a list comprehensio...It's exactly equivalent to a list comprehension. Whenever you see:<br /><br /> do x <- [a, b]; y <- [c, d]; return (f x y)<br /><br />... translate it in your mind to:<br /><br /> [ f x y | x <- [a, b], y <- [c, d] ]<br /><br />See also this post:<br /><br />http://www.haskellforall.com/2014/10/how-to-desugar-haskell-code.htmlGabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-26402901623426253182015-10-24T22:00:15.674-07:002015-10-24T22:00:15.674-07:00Great post, Gabriel. :)
I have a question about w...Great post, Gabriel. :)<br /><br />I have a question about what's happening in #5: It would appear that `stories` is building a list of all possible combinations of the inner strings and lists. However, it's not clear to me where or why that's happening. Is that something that the List's monad's bind does implicitly?Unknownhttps://www.blogger.com/profile/12274807158417256625noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-32439702164747801332015-10-14T08:22:57.407-07:002015-10-14T08:22:57.407-07:00Very helpful, thanks!Very helpful, thanks!Anonymoushttps://www.blogger.com/profile/08739139616634379913noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-55242882589130428292015-10-14T04:24:48.653-07:002015-10-14T04:24:48.653-07:00Nice post indeed! :)Nice post indeed! :)Anonymoushttps://www.blogger.com/profile/06180476773002153033noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-61229786487783409762015-10-11T13:25:25.846-07:002015-10-11T13:25:25.846-07:00I actually kind of like your implementation better...I actually kind of like your implementation betterGabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-83512522151107566782015-10-11T13:18:09.352-07:002015-10-11T13:18:09.352-07:00FixedFixedGabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-77370925765325695752015-10-11T13:02:37.077-07:002015-10-11T13:02:37.077-07:00You're welcome!You're welcome!Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-1268089763342813632015-10-09T06:46:58.875-07:002015-10-09T06:46:58.875-07:00Great post, thanks.Great post, thanks.Anonymoushttps://www.blogger.com/profile/08915240893699033323noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-11627022871519538052015-10-08T16:51:47.762-07:002015-10-08T16:51:47.762-07:00This post really puts the 'for all' in ...This post really puts the 'for all' in 'Haskell for all'.Yawarhttps://www.blogger.com/profile/13741563704441932843noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-79487786711016238742015-10-08T15:20:10.534-07:002015-10-08T15:20:10.534-07:00Fantastic post.Fantastic post.Leonhttps://www.blogger.com/profile/12711285313237764064noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-89166701432180105902015-10-08T14:57:22.618-07:002015-10-08T14:57:22.618-07:00That would be amazing.That would be amazing.Paul Driverhttps://www.blogger.com/profile/10237023548706204076noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-24672454322993897042015-10-08T03:36:21.849-07:002015-10-08T03:36:21.849-07:00Great idea!
Next step: Add a SYNOPSIS section to ...Great idea!<br /><br />Next step: Add a SYNOPSIS section to all Haskell-libraries, with an example of how to use the library (see CPAN).<br /><br />I can wish, can't I? :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-75886306258603363042015-10-07T23:55:45.708-07:002015-10-07T23:55:45.708-07:00I believe you can replace "n' `seq` delet...I believe you can replace "n' `seq` delete n' as" with "delete n' as", as "delete" is strict in its first argument.nomeatahttps://www.blogger.com/profile/05986291481431063004noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-68690454927057090322015-10-07T23:14:01.240-07:002015-10-07T23:14:01.240-07:00Have a look at https://wiki.haskell.org/H-99:_Nine...Have a look at https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_ProblemsERhttps://www.blogger.com/profile/03258933511567612521noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-78744019134584738302015-10-07T23:11:59.284-07:002015-10-07T23:11:59.284-07:00I'm curious about the operational differences ...I'm curious about the operational differences with the `splitOn` implementation at http://lpaste.net/142548 . Is it a matter of trading off stack space for heap space (or something like that)?ERhttps://www.blogger.com/profile/03258933511567612521noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-46882824383561308902015-10-07T22:53:14.274-07:002015-10-07T22:53:14.274-07:00How about a Haskell version of https://www.ic.unic...How about a Haskell version of https://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html ?Anonymoushttps://www.blogger.com/profile/04774920678364626791noreply@blogger.com