
So I'm picking up Haskell bit by bit, and I found the code examples transpiring here most useful. Reflecting why it's harder to pick up Haskell than say Ruby or Python, here's what I found -- those languages deal with a typical domain available to any programmer -- his own computer/system/shell. The artifacts are files, directories, timestamps, etc. The stuff every programmer understands in their sleep. APIs. So I loved the shell-script beautification thread. That's how I learn about new modules and their functions -- as use cases. I also found some pieces of Haskell strewn around people's websites, blogs, forums; even at paste.lisp.org. I'm gathering them for my own purpose and trying to compile and run them. Wouldn't it be nice -- in case it doesn't exist already -- a[n O'Reilly[-like]] Haskell Cookbook? That would be the best way to learn Haskell. I've found a wikibook on Haskell, but I look for a big bag of small, self-contained programs. Perhaps you esteemed veterans can dig your small scripts and paste them into a wiki? Examples needed -- how to connect to a database; to a web service (e.g. Amazon); read a csv file; represent data equivalent to a directory listing; a text file/XML; etc... Cheers, Alexy

deliverable:
So I'm picking up Haskell bit by bit, and I found the code examples transpiring here most useful. Reflecting why it's harder to pick up Haskell than say Ruby or Python, here's what I found -- those languages deal with a typical domain available to any programmer -- his own computer/system/shell. The artifacts are files, directories, timestamps, etc. The stuff every programmer understands in their sleep. APIs. So I loved the shell-script beautification thread. That's how I learn about new modules and their functions -- as use cases.
I also found some pieces of Haskell strewn around people's websites, blogs, forums; even at paste.lisp.org. I'm gathering them for my own purpose and trying to compile and run them.
That reminds me, there's lots of very nice code on Haskell paste, http://hpaste.org/ You could dump a lot of that into a cookbook, almost. -- Don

On 1/30/07, Donald Bruce Stewart
That reminds me, there's lots of very nice code on Haskell paste,
You could dump a lot of that into a cookbook, almost.
Thanks for the link, lovely, but very linear -- and not classified, and not browseable even. I clicked a bit until my mouse got tired and there was only 5d age on display. How about dumping this whole codebase into a search engine such as Lucene? Is it available in more useful form for browsing/study? (Even a tarball form will be fine...) Cheers, Alexy

Also see that sequence.complete.org has many code snippets in the blog section. What would be a good way to systematize all such snippets together with hpaste.org and those scrolling through the mailing list? Perhaps some kind of ontology of snippets like the table of contents of a cookbook? Cheers, Alexy

Hi, On 1 Feb 2007, at 00:50, Alexy Khrabrov wrote:
Also see that sequence.complete.org has many code snippets in the blog section. What would be a good way to systematize all such snippets together with hpaste.org and those scrolling through the mailing list? Perhaps some kind of ontology of snippets like the table of contents of a cookbook?
How about using a tag cloud? Alike to del.icio.us? -- Andy

On 31/01/07, Alexy Khrabrov
Wouldn't it be nice -- in case it doesn't exist already -- a[n O'Reilly[-like]] Haskell Cookbook? That would be the best way to learn Haskell. I've found a wikibook on Haskell, but I look for a big bag of small, self-contained programs. Perhaps you esteemed veterans can dig your small scripts and paste them into a wiki?
*Absolutely* !!! I'm far from a veteran, but I had intended, when I got some free time, to knock up a "Cookbook" section on the wiki. I don't see any reason why a newcomer like me shouldn't do this - in many ways, it's better to start with some examples from a newcomer's perspective ("these are the sort of things I found useful") to show the more experienced people what we're looking for. So if you have spare time, I'd say you should feel free to do this yourself. I'd happily contribute. Otherwise, if you wait, I'll get round to starting it - but be prepared for quite a long wait, as spare time is in extremely short supply for me just now :-)
Examples needed -- how to connect to a database; to a web service (e.g. Amazon); read a csv file; represent data equivalent to a directory listing; a text file/XML; etc...
These all sound good. I was planning on knocking up a "how to get the results of a query from an Oracle database using Takusen" entry as my starting point, because that's an example I encountered recently (and I got a lot of help from the list, so I'd like to give something back). All I need now is a spare evening... Paul.

Quoth Paul Moore, nevermore,
why a newcomer like me shouldn't do this - in many ways, it's better to start with some examples from a newcomer's perspective ("these are the sort of things I found useful") to show the more experienced people what we're looking for.
I agree with this. I think many people start with the idea of simple text processing or something (like summing a list of numbers from a text file, say) but that stuff isn't really covered because it's so trivial. But it can be difficult to realise how trivial it is. :) Hmm, that doesn't make a whole lot of sense, but you see what I'm getting at. The cookbook approach is great; it's a real shame that the one Haskell cookbook implementation out there (it was a reworking of a perl book I think? I can't remember the name) was barely recognisable as Haskell at all. I think the entire Prelude had been hidden and all the operators redefined as other things. Maybe it would be useful to start on that, but using idiomatic Haskell rather than obfuscated Haskell. Cheers, Dougal

ithika:
Quoth Paul Moore, nevermore,
why a newcomer like me shouldn't do this - in many ways, it's better to start with some examples from a newcomer's perspective ("these are the sort of things I found useful") to show the more experienced people what we're looking for.
I agree with this. I think many people start with the idea of simple text processing or something (like summing a list of numbers from a text file, say) but that stuff isn't really covered because it's so trivial. But it can be difficult to realise how trivial it is. :)
Hey, we have a whole page for that program! http://haskell.org/haskellwiki/Shootout/SumFile -- Don

On Wed, 2007-31-01 at 09:50 +0000, Dougal Stanton wrote:
Hmm, that doesn't make a whole lot of sense, but you see what I'm getting at. The cookbook approach is great; it's a real shame that the one Haskell cookbook implementation out there (it was a reworking of a perl book I think? I can't remember the name) was barely recognisable as Haskell at all. I think the entire Prelude had been hidden and all the operators redefined as other things. Maybe it would be useful to start on that, but using idiomatic Haskell rather than obfuscated Haskell.
How about working from the Python Cookbook and going back to Haskell? Given how many concepts recent versions of Python borrowed from Haskell, perhaps it's time to borrow stuff back from them? ;) -- Michael T. Richter Email: ttmrichter@gmail.com, mtr1966@hotpop.com MSN: ttmrichter@hotmail.com, mtr1966@hotmail.com; YIM: michael_richter_1966; AIM: YanJiahua1966; ICQ: 241960658; Jabber: mtr1966@jabber.cn "I do not understand this sqeamishness about the use of gas. I am strongly in favour of using poison gas against uncivilised tribes." --Winston Churchill

Dougal Stanton
Hmm, that doesn't make a whole lot of sense, but you see what I'm getting at. The cookbook approach is great; it's a real shame that the one Haskell cookbook implementation out there (it was a reworking of a perl book I think? I can't remember the name) was barely recognisable as Haskell at all. I think the entire Prelude had been hidden and all the operators redefined as other things. Maybe it would be useful to start on that, but using idiomatic Haskell rather than obfuscated Haskell.
(about http://pleac.sf.net/) pleac is coming along quite nicely, with some active contributers (ocaml, groovy...) as for the haskell entry, Yoann Padioleau wanted to show haskell could be very expressive, so he introduced many new functions/operators. The haskell entry should be renamed because it's really a domain specific embedded language :-) (see http://pleac.sourceforge.net/pleac_haskell/a1102.html) But this does not follow the pleac goal, which aims at showing how to do something the "standard" way. I'm planning to contribute a new haskell entry to pleac, based on Yoann's, but getting rid of the all the wonderful weird stuff, ie plain old haskell :) If someone wanna do it before me (since alas i can't allocate much time on it), please do! -- Pascal Rigaux - http://merd.net/pixel/language-study/syntax-across-languages

Alexy Khrabrov wrote:
Reflecting why it's harder to pick up Haskell than say Ruby or Python, here's what I found -- those languages deal with a typical domain available to any programmer -- his own computer/system/shell. The artifacts are files, directories, timestamps, etc. The stuff every programmer understands in their sleep. APIs. So I loved the shell-script beautification thread.
Note that there is an inherent difficulty with files, directories, pipes: they are not purely functional in style. While it's unavoidable that writeFile :: FilePath -> String -> IO () is in IO, I think that readFile :: FilePath -> IO String would not need to be in IO if the file system would be persistent (not ephemeral). Pipes are an ugly way to implement lazy evaluation. For instance, take the pipe "ls -l | grep '*.hs'". To achieve the effect that "grep" immediately feeds on the data "ls -l" spits out, both programs are run concurrently and blocking keeps in line. This does not generalize so well to multiple data sources, something lazy evaluation has no problems with. And one of the main problems is that current OS see programs as things of type "String -> IO String". Of course, pure and strongly typed programs would be preferred. So, instead of calling system ("ghc -O2 -c " ++ show filepath) we want GHC.desugar :: GHC.Haskell' -> GHC.Core GHC.optimize :: GHC.Core -> GHC.Core GHC.assemble :: GHC.Core -> OS.Program In a sense, current OS are not ready for Haskell yet. Regards, apfelmus
participants (8)
-
Alexy Khrabrov
-
Andy Georges
-
apfelmus@quantentunnel.de
-
dons@cse.unsw.edu.au
-
Dougal Stanton
-
Michael T. Richter
-
Paul Moore
-
Pixel