Why Perl is more learnable than Haskell

Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.) Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite. I've been wanting to learn Haskell for years, literally, but it has been a case of Sisyphus and the Rock. Despite my efforts, I never get to the level of expertise that would make Haskell useful to me. (I don't need elegant factorial or Fibonacci functions in my everyday work.) Sooner or later life intervenes: big project due, long trip abroad, etc., and when I finally return to learning Haskell, I have forgotten almost everything I learned and I have to start all over again. (BTW, I've heard similar stories from many wannabe Haskell programmers.) Arguably, this experience means that I have no business learning Haskell, because it's just not relevant to my work. Maybe so, but I still cling to the fanciful notion that if I knew Haskell well enough, I would find plenty of stuff to do with it in my daily work... Anyway, in contrast to my struggle with Haskell, I learned Perl incrementally over the years, by using it in daily little projects, ranging at first from command-line snippets to 100-line self-contained scripts, and moving on to larger, hairier projects. This daily reinforcement of the little bits of Perl I was picking up was crucial to my being able to retain it and move forward. Perhaps Haskell will never lend itself to something like a Perl one-liner, but still I wish that there were books on Haskell that focused on making Haskell useful to the learner as quickly as possible... If such already exist and I've missed it, please let me know. Or I can always wait until I retire; then I'll probably have a sufficiently long stretch of free time in my hands (barring any operations, strokes, heart attacks, hip fractures, etc.). I bet I could start a Haskell Wannabes Club at the nursing home... kj -- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

kynnjo:
Perhaps Haskell will never lend itself to something like a Perl one-liner, but still I wish that there were books on Haskell that focused on making Haskell useful to the learner as quickly as possible... If such already exist and I've missed it, please let me know.
There's some things in the works, but for now you can perhaps find something relevant to what you're trying to do here, http://haskell.org/haskellwiki/Blog_articles There's a good breadth of topics covered. Also, I recommend hanging out on #haskell, you'll just see so many interesting haskell snippets, have people to help answer questions, and of course, the lambdabot, that you can't help but learn haskell by osmosis! http://haskell.org/haskellwiki/IRC_channel Good luck. Hope to see you online. -- Don P.S. Have a fix point! Control.Monad.Fix.fix ((1:) . scanl (+) 1)

My opinion is that "learnin haskell is difficult" is just for the fact that
when you learn programming, you probably begin with C / C++ or some other
procedural/OO programming language, so you get used to think in these ways,
and when you have to switch to functional paradigm, you find it difficoult.
If you first language is LISP probably you find easy Haskell and difficult
pearl.
2007/4/11, kynn
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite.
I've been wanting to learn Haskell for years, literally, but it has been a case of Sisyphus and the Rock. Despite my efforts, I never get to the level of expertise that would make Haskell useful to me. (I don't need elegant factorial or Fibonacci functions in my everyday work.) Sooner or later life intervenes: big project due, long trip abroad, etc., and when I finally return to learning Haskell, I have forgotten almost everything I learned and I have to start all over again. (BTW, I've heard similar stories from many wannabe Haskell programmers.)
Arguably, this experience means that I have no business learning Haskell, because it's just not relevant to my work. Maybe so, but I still cling to the fanciful notion that if I knew Haskell well enough, I would find plenty of stuff to do with it in my daily work...
Anyway, in contrast to my struggle with Haskell, I learned Perl incrementally over the years, by using it in daily little projects, ranging at first from command-line snippets to 100-line self-contained scripts, and moving on to larger, hairier projects. This daily reinforcement of the little bits of Perl I was picking up was crucial to my being able to retain it and move forward.
Perhaps Haskell will never lend itself to something like a Perl one-liner, but still I wish that there were books on Haskell that focused on making Haskell useful to the learner as quickly as possible... If such already exist and I've missed it, please let me know.
Or I can always wait until I retire; then I'll probably have a sufficiently long stretch of free time in my hands (barring any operations, strokes, heart attacks, hip fractures, etc.). I bet I could start a Haskell Wannabes Club at the nursing home...
kj
-- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. (Alan Kay)

On 4/11/07, riccardo cagnasso
If you first language is LISP probably you find easy Haskell and difficult pearl.
I must say I agree here. I spent 10 years programming in prolog before I tried haskell. Most of my problems with haskell are because it has a rather opaque performance model (e.g. when should you use tail recursion, and when should you not). But I happily acknowledge that my experience is probably atypical. ;-) cheers, T. -- Dr Thomas Conway You are beautiful; but learn to work, drtomc@gmail.com for you cannot eat your beauty. -- Congo proverb

... I spent 10 years programming in prolog before I tried haskell. Most of my problems with haskell are because it has a rather opaque performance model (e.g. when should you use tail recursion, and when should you not). But I happily acknowledge that my experience is probably atypical. ;-)
Hmmmm.... After 10 years you should have under your skin the feeling when you would like to use backtracking, and when the "forward", recursive loop in Prolog, don't you? Well, it requires just a little twist to acquire a similar feeling with Haskell: when should one loop using tail recursion, and when it is preferable to act incrementally, deferring the construction of a data piece until its consumption. Prolog was one of the first languages I learnt (centuries ago, when it used the Marseille syntax...), and I must say that it *helped* me with Haskell. But anyway, programming languages require first a good deal of positive thought. The discussion on the relative merits of X or Y is OK, but when I read that someone hates Perl, and somebody else hates Matlab, I am a bit sick. Hatred never produced anything. Jerzy Karczmarczuk

riccardo cagnasso wrote:
My opinion is that "learnin haskell is difficult" is just for the fact that when you learn programming, you probably begin with C / C++ or some other procedural/OO programming language...
Actually, my first language was Scheme; I loved it, and I aced the class, but that was many years ago, and I never had to code "real world" applications with Scheme. My problems with Haskell are not conceptual, but rather pragmatic. I have not been able to find enough support in Haskell for everyday tasks (e.g. read a stream from a socket; parse it into a simple data structure; process the data in the structure; print out the results to a socket; etc.), and unless I want to code large low-level libraries from scratch just to get conceptually simple tasks done, I can't afford to use Haskell (any more than I could afford to use barebones C, for that matter). And even though my interest in learning Haskell is not a "pragmatic" one (I'm quite productive with the tools I know; I just want to learn a new way to program, by way of intellectual curiosity), my life is such that, unless I can immediately make use of the language I'm attempting to learn, it just won't stick! The language needs it to be useful not because I need a tool, but because unless it is useful my brain just won't absorb it! kj -- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Apr 11, 2007, at 23:10 , kynn wrote:
rather pragmatic. I have not been able to find enough support in Haskell for everyday tasks (e.g. read a stream from a socket; parse it into a simple
The stuff in Network (not Network.Socket) gives you a Handle, which you can treat more or less like any other Haskell Handle (filehandle). Network.Socket should be reserved for when you need to work at a really low level. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Hello kynn, Thursday, April 12, 2007, 7:10:56 AM, you wrote:
rather pragmatic. I have not been able to find enough support in Haskell for everyday tasks (e.g. read a stream from a socket; parse it into a simple data structure; process the data in the structure; print out the results to a socket;
look here: http://haskell.org/haskellwiki/Library/AltBinary -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On 4/11/07, kynn
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite.
I've been trying to learn Haskell for some time also, and I've learnt lots of various other languages in the past. I think one of the biggest problems is if there is a considerable learning curve, which Haskell undoubtedly has, there's a nagging question in the back of your head while you try and get a simple task accomplished in an unfamiliar language - "why am I bothering with this, I could do it in 5 minutes in Perl/Python/Ruby/...!". And for many simple tasks Perl is a really good fit - it's best to find a task that plays to Haskell's strengths so you get a bit of positive reinforcement while you work. I have been working with Parsec to do some parsing recently and I can definitely recommend it. I don't think I've used such a capable and easy to use parsing framework in any language and it's really kept me going with Haskell where I might have "just done it in Python" in the past.

On Wed, Apr 11, 2007 at 02:21:41PM +0100, Will Newton wrote:
On 4/11/07, kynn
wrote: Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite.
I've been trying to learn Haskell for some time also, and I've learnt lots of various other languages in the past. I think one of the biggest problems is if there is a considerable learning curve, which Haskell undoubtedly has, there's a nagging question in the back of your head while you try and get a simple task accomplished in an unfamiliar language - "why am I bothering with this, I could do it in 5 minutes in Perl/Python/Ruby/...!".
And for many simple tasks Perl is a really good fit - it's best to find a task that plays to Haskell's strengths so you get a bit of positive reinforcement while you work. I have been working with Parsec to do some parsing recently and I can definitely recommend it. I don't think I've used such a capable and easy to use parsing framework in any language and it's really kept me going with Haskell where I might have "just done it in Python" in the past.
Writing interpreters is one task where Haskell is really nice. I suggest Unlambda, it makes a nice toy language. The syntax is easy to work with, and continuations make the semantics interesting enough that you can't just rely on the host language acting the same way, like you generally can with mutable state, sequential evaluation and so on (unless you're using something like scheme or ml, but then you probably wouldn't have trouble with Haskell). Brandon

Sorry to hear of your struggles. There has been a lot of work lately on writing Haskell tutorials but there's still a long way to go, unfortunately, as I discovered when I tried recently to find the collection of sample code fragments on the wiki that I'm sure are around somewhere. I had the advantage of coming to Haskell after already having used ML and Common Lisp. But, FWIW, I found it worth persevering: I liked a lot of my legacy Perl scripts more after I ported them to Haskell and now I use Haskell for the sort of thing I might have used bash or perl for previously. (For instance, on the way home last night my GPS' NMEA-0183 data was odd enough that I used Haskell to write a simple daemon that sits between clients and my gpsd and rewrites their conversation; previously, I'd have used Perl for that.) Though, it helps if you get on well with Perl. It didn't suit me very well so I had more motivation to switch than you might. But, now, by choice, I do use Haskell for the kind of thing I'd have previously used a short script for instead, so there might still be light at the end of the tunnel for you. -- Mark

I am also coming at haskell from a perl background.
While there is some truth to what you say, I do think haskell can be
used for "keeping simple things simple" in a way similar to perl.
Though you have to search harder since the documentation / tutorials
seem to be more optimized for "making hard things possible". (And in
fact, much easier than in perl.)
But back to the easy, here is a thread concerning one liners in haskell
http://groups.google.de/group/fa.haskell/browse_thread/thread/e948ff0ad4d7c0c9/ac0a46d1f841db59?lnk=st&q=haskell+one+liners&rnum=1&hl=en#ac0a46d1f841db59
I think if you really have desire the best route is to complement
googling around with asking on #haskell and the newsgroups. It's a
*very* friendly community.
hope this helps!
2007/4/11, kynn
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite.
I've been wanting to learn Haskell for years, literally, but it has been a case of Sisyphus and the Rock. Despite my efforts, I never get to the level of expertise that would make Haskell useful to me. (I don't need elegant factorial or Fibonacci functions in my everyday work.) Sooner or later life intervenes: big project due, long trip abroad, etc., and when I finally return to learning Haskell, I have forgotten almost everything I learned and I have to start all over again. (BTW, I've heard similar stories from many wannabe Haskell programmers.)
Arguably, this experience means that I have no business learning Haskell, because it's just not relevant to my work. Maybe so, but I still cling to the fanciful notion that if I knew Haskell well enough, I would find plenty of stuff to do with it in my daily work...
Anyway, in contrast to my struggle with Haskell, I learned Perl incrementally over the years, by using it in daily little projects, ranging at first from command-line snippets to 100-line self-contained scripts, and moving on to larger, hairier projects. This daily reinforcement of the little bits of Perl I was picking up was crucial to my being able to retain it and move forward.
Perhaps Haskell will never lend itself to something like a Perl one-liner, but still I wish that there were books on Haskell that focused on making Haskell useful to the learner as quickly as possible... If such already exist and I've missed it, please let me know.
Or I can always wait until I retire; then I'll probably have a sufficiently long stretch of free time in my hands (barring any operations, strokes, heart attacks, hip fractures, etc.). I bet I could start a Haskell Wannabes Club at the nursing home...
kj
-- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
i find that don's "haskell hacking blog" has been written with the daily hacker in mind: http://cgi.cse.unsw.edu.au/~dons/blog my own experience is that i would gladly replace perl for many tasks if haskell's libraries were *easier to use*. for common and simple tasks like reading data from a network resource (http, ftp), querying a database, accessing xml (dom, etc), its more important to me to have an api that is simple to use than one that takes an "interesting" approach. perl's apis for these tasks tend to be very simple. hackage seems to be on track to deliver the advantages of the cpan tool and repository, so in that sense i think one of the key advantages of perl has been adopted by the haskell community. both languages have great communities!

The post on dons' blog about the cpu scaler is a great example on how
haskell can easily used in the day-to-day hacking!
2007/4/11, brad clawsie
i find that don's "haskell hacking blog" has been written with the daily hacker in mind:
http://cgi.cse.unsw.edu.au/~dons/bloghttp://cgi.cse.unsw.edu.au/%7Edons/blog _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. (Alan Kay)

Hallo,
On 4/11/07, riccardo cagnasso
The post on dons' blog about the cpu scaler is a great example on how haskell can easily used in the day-to-day hacking!
Just read it, it's a very nice post. I'm not afraid of math, but it's a relief to see some code I can relate with. :-) -- -alex http://www.ventonegro.org/

Hi. I can't find that post. Could you point it to me please? Thanks! kj riccardo cagnasso wrote:
The post on dons' blog about the cpu scaler is a great example on how haskell can easily used in the day-to-day hacking!
2007/4/11, brad clawsie
: i find that don's "haskell hacking blog" has been written with the daily hacker in mind:
http://cgi.cse.unsw.edu.au/~dons/bloghttp://cgi.cse.unsw.edu.au/%7Edons/blog _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. (Alan Kay)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Hallo,
On 4/12/07, kynn
Hi. I can't find that post. Could you point it to me please?
It's in here: http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10#programmable-semicolons -- -alex http://www.ventonegro.org/

On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite. Haskell useful to the learner as quickly as possible... If such already
....snip
exist and I've missed it, please let me know.
Or I can always wait until I retire; then I'll probably have a sufficiently long stretch of free time in my hands (barring any operations, strokes, heart attacks, hip fractures, etc.). I bet I could start a Haskell Wannabes Club at the nursing home...
kj
My experience is a lot like yours, except I retired 5 years ago, and still haven't learned Haskell. Unfortunately, I've had lots of interruptions that have kept me away from the keyboard. I've got a few unfinished projects, including one I started in Perl years ago, moved to Python, then moved to Haskell. The only useful thing I've programmed since I retired was a program to update my checkbook/bank statement postgresql database using Prolog for parsing entries the way I like to write them in a text file. Someday I'll move this to Haskell :-). I've sworn off other languages since I don't have any deadlines except my own. I never really learned Perl, but I used it a lot for simple one to thirty liners. The thing was, any thing I wanted to do I could find the bits and pieces of in "Learning Perl", "Programming Perl", or "Learning Perl/TK". I have on my shelf "Haskell: The craft...", "The Haskell school of expression", and "The Haskell road to Logic...". I've "read" them. I know I should sit down with each one at the computer and work through the exercises. But..,. When my current spate of unavoidable interruptions is over, I'll look into the email on Haskell one-liners, and some of the new tutorials to try to come back up to speed. Not in a nursing home yet! Good luck, John Velman

kynn wrote:
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
[snip]
May I ask why you want to learn it so much, if you find it so hard? I'm sure most would disagree with me but maybe you'd be better off with perl for your one liners and scripts if it serves your purpose well. You say that you've heard Haskell is extremely elegant, but is that really the reason you want to start using it as your general purpose and scripting language? I'm also interested in it myself because of it's elegance, and in order to learn different paradigms, to explore the strength of the type system etc etc, but I'm not in a particular rush to be able to use it as the one true language for scripting or web applications, or xyz, as quite a few people lately seem to be asking about. Just curious. -- View this message in context: http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
Perl is a large, ugly, messy language filled with quirks and eccentricities, while Haskell is an extremely elegant language whose design is guided by a few overriding ideas. (Or so I'm told.)
Based on this one would think that it would be much easier to learn Haskell than to learn Perl, but my experience is exactly the opposite.
Perhaps it's just that being more elegant doesn't make it easier to learn. There are almost no overriding ideas in SKI combinator calculus, but I wouldn't say it's a nice and easy programming language (Well, OK, I didn't try to master it, so maybe I'm wrong). The biggest problem with Haskell is that not only you can do things differently (than in other languages) - you have to! Also, some tasks are only easy when you know some advanced programming techniques, like parsing with parser combinators. There is also the problem that fundamental concepts are quite entangled, and it's difficult to choose the starting point when learning or teaching. The language also seems a bit schizophrenic. For example, you can say that it has side-effects and that it has no side-effects, and both statements are true in some sense (expression evaluation has no side-effects but there are features like IO, mutable arrays, etc. - it's quite difficult to explain to beginners why there is no contradiction, or where is the trick, in other words). Actually, I don't know which is the biggest problem... and there are more of them. Best regards Tomasz

kynn wrote:
(I don't need elegant factorial or Fibonacci functions in my everyday work.)
I think you do. Most of your utility programs probably fit into the simple frame of main = interact $ unlines . map f . lines for suitable f. Of course, f is hardly ever the factorial function, but it is a function. My guess is, you think you "just wanted a loop" when in reality you need to lift a function to work over a list.
Or I can always wait until I retire; then I'll probably have a sufficiently long stretch of free time in my hands
You may need patience, too. -Udo

Friends I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/ I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics. One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were. So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out: Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10 But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author. Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done". Thanks! Simon

What about demonstrating the use of an Haskell interpreter as a pimped up
calculator?
multTable = putStr $ unlines [unlines [show x ++ ' ':show y ++ ' ':show
(x*y)|y<-[1..10]] | x<-[1..10]]
2007/4/16, Simon Peyton-Jones
Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Dipl.-Inform. Steffen Mazanek Institut für Softwaretechnologie Fakultät Informatik Universität der Bundeswehr München 85577 Neubiberg Tel: +49 (0)89 6004-2505 Fax: +49 (0)89 6004-4447 E-Mail: steffen.mazanek@unibw.de

Give them a program that selects a bunch of files based on some
filtering criteria, and then does something to each file.
Kind of like find + xargs, but using haskell instead. Good recipe for sysadmins.
There was a recent example involving parsing raw emails into a thread here
http://groups.google.de/group/fa.haskell/browse_thread/thread/b80dc2836f63f270/4a020e087e5b2060?lnk=st&q=%22haskell+cafe%22+email+&rnum=3&hl=en#4a020e087e5b2060
Maybe that could be simplified and something could be based on that.
A one-liner using PCRE regex might also be of use.
2007/4/16, Simon Peyton-Jones
Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 16/04/07, Thomas Hartman
Maybe that could be simplified and something could be based on that.
A one-liner using PCRE regex might also be of use.
Unless it can be performed with astounding dexterity, I don't think try to beat, for example, Perl at its own game will produce worthwhile results. What, instead, is Haskell's unique selling point? Non-strictness? Purity? Optional, composable, computation styles (ie, drop-in monads for non-determinism, continuations, state etc)? Succinct and elegant syntax? Something else? Cheers, D.

There may be something to this point of view.
On the other hand, it is easier for me to see examples that can
connect back to something I am already familiar with.
That said, I will mention something where perl *seemed* to be a fit,
but later proved frustrating. To whit -- Doing something at the shell
level, in parallel. Ideally, in such a way that it could scale to, for
example, multiple processes on a multi processor box, or even
distributed map-reduce using a botnet.
I just couldn't figure out a good way to do this in perl, despite a
recently published map-reduce module to the CPAN. It all just seemed
to get icky. I couldn't "plug in" my bits of finished code in the way
I would have liked to, forking and other fiddly bits just seemed to
get in the way.
Now, this is probably largely due to my inexperience with "parallel"
thinking. However, I think part of it is also the limitations in the
language.
My simple task was to download a bunch of urls. This could be done
with wget. What I got frustrated with was, speeding this up by doing
things in parallel. There are a number of modules on the CPAN that
purport to help with this... parallel fork manager... parallel web
user agent... others... but things got messy fast, even through the
core task (fetch a url) was extremely simple. That is something that
got me thinking.
So, an example to take a simple task (eg web fetch, but could be
something else), and then scale it to work in parallel -- with
threads, with map reduce, howsoever -- might be a good show of
haskell's strehgths. I think there was even a post to haskell cafe
about this today.
To recap: transform a piece of simple code that works in serial, so it
works in parallel. Maybe even a couple, or three ways: using forks,
using threads, using map reduce.
Compare and contrast this with doing the same transformation in perl.
Perl should be messier.
Hope this helps...
2007/4/16, Dougal Stanton
On 16/04/07, Thomas Hartman
wrote: Maybe that could be simplified and something could be based on that.
A one-liner using PCRE regex might also be of use.
Unless it can be performed with astounding dexterity, I don't think try to beat, for example, Perl at its own game will produce worthwhile results.
What, instead, is Haskell's unique selling point? Non-strictness? Purity? Optional, composable, computation styles (ie, drop-in monads for non-determinism, continuations, state etc)? Succinct and elegant syntax? Something else?
Cheers,
D. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, 2007-04-16 at 13:27 +0200, Thomas Hartman wrote:
To recap: transform a piece of simple code that works in serial, so it works in parallel. Maybe even a couple, or three ways: using forks, using threads, using map reduce.
This made me think of one of my favorite observations. You occasionally hear how the wonderful static type system just forces your program to be correct: if they compile, they work. We all know that this is an exaggeration, but there is one case when this seems to apply - when refactoring already working code. IME, it seems that whenever I tear my programs apart, as long as the type checker agrees the pieces all fit back together, the program works as i expect it to. (Perhaps not so easy to apply this to a tutorial setting?) -k

On 4/16/07, Ketil Malde
On Mon, 2007-04-16 at 13:27 +0200, Thomas Hartman wrote:
To recap: transform a piece of simple code that works in serial, so it works in parallel. Maybe even a couple, or three ways: using forks, using threads, using map reduce.
This made me think of one of my favorite observations.
You occasionally hear how the wonderful static type system just forces your program to be correct: if they compile, they work. We all know that this is an exaggeration,
No we don't! At least not anywhere near as much of an exaggeration as that statement would be about an strongly typed imperative language (sequencing can't be type checked*, imperative programs are mostly sequencing, thus imperative programs are mostly unchecked). Strong static typing + expression-based programming + rich support for custom data types = "if the compiler doesn't beep, the program almost always works". I think this is a key selling point. Not sure how to convince people it's actually true in a 3 hour tutorial, though. * well, you can check scoping, but that's about it, right?
-- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

No we don't! At least not anywhere near as much of an exaggeration as that statement would be about an strongly typed imperative language (sequencing can't be type checked*, imperative programs are mostly sequencing, thus imperative programs are mostly unchecked).
Actually, side effects *can* be type checked, but it's a lot more painful (the type of an assignment is not nearly as simple as the one you're used to). Stefan

On Mon, 2007-04-16 at 11:06 +0100, Dougal Stanton wrote:
A one-liner using PCRE regex might also be of use.
Unless it can be performed with astounding dexterity, I don't think try to beat, for example, Perl at its own game will produce worthwhile results.
One possibility is a task where the Perl hacker will pull out regular expressions, but where cleaner and more maintainable code can be written using Haskell. Possibly parsing a relatively simple, line based format with 'words', 'concat', 'split', et al.? Or a recursive format? -k

Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon I'm really enthusiastic about parsec. Even though the principles are (still) far above my head, I've been able to use it on a .csv table
On Mon, 2007-04-16 at 09:34 +0100, Simon Peyton-Jones wrote: produced by OO Calc (the spreadsheet). The tutorial is also very good, and maybe parsec is also an example of (possible) interaction of Haskell to 'modules' written in other programming languages. You can do something (simple but useful) with parsec after just an afternoon's reading. fwiw, summing up my own Haskell experience: I've been learning Haskell for a year now, and I find it very difficult. I miss a training in computer science and often I feel like the guy in that movie who's on a 500 mile trip driving an old lawn mower. Traffic zooms past, and often you depend on people who're willing to lend a hand. Having said that, it's also fun and I enjoy the pioneer spirit in the community. The major advantages of Haskell are, IMO, 1) the type system is a great aid to the programmer and programs are short. Therefore Haskell is very well suited for the independent developer who can't afford huge amounts of code. Open Source has many of those. 2) polymorphism is also a great advantage. You can write your program in the most general types using e.g. only equality and order, and fine tune them later to more specific types which perform better. 3) the difficulty of Haskell is not necessarily a bad thing, it also makes it interesting, and there are many good libraries to use. But Haskell is also pretty scaleable, in the sense that you can do a lot of things just with recursion, then do them better with maps, folds, list comprehensions, then do them better with some monadic replacements, and so on. 4) there is a very helpful and knowledgeable community. A major disadvantage of Haskell is the lack of books, especially with regard to intermediate level programming and the libraries. Documentation that is available varies in quality and is, in general, fragmented. Best Regards, Hans van Thiel

Hi I think its important to cover whats different about Haskell. Things like laziness are cool, but are harder to convince a strict programmer that they are useful. Types however are obviously very handy, if you can focus on why a Haskell program is so obviously correct easily.
1) the type system is a great aid to the programmer and programs are short. Therefore Haskell is very well suited for the independent developer who can't afford huge amounts of code. Open Source has many of those.
I'd also at least demonstrate Hoogle, but perhaps I'm biased :-)
2) polymorphism is also a great advantage. You can write your program in the most general types using e.g. only equality and order, and fine tune them later to more specific types which perform better.
I'd also focus on the fact that polymorphism can be inferred, in things like C++/Ada using polymorphism means littering the code with hints about the polymorphism. Thanks Neil

"Neil Mitchell"
I think its important to cover whats different about Haskell. Things like laziness are cool, but are harder to convince a strict programmer that they are useful. (snip)
Mmmm, it took me a while to really find laziness useful, and that was normally to let me create complex things that were mutually dependent on each other, releasing me from some housekeeping - some calculation in one would help the other creep along, and vice versa. I'm afraid no examples come easily to mind, though. BTW, I wonder if it's too much difficulty to show off STM. -- Mark

Mark T.B. Carroll wrote:
I'm afraid no examples come easily to mind, though.
Here's a simple one: reading a flattened graph from disk. If your flattened representation contains forward references, you have to fix them up in a strict language. In a lazy language, you can refer to elements you haven't yet read, eliminating that book-keeping.

Bryan O'Sullivan
Mark T.B. Carroll wrote:
I'm afraid no examples come easily to mind, though.
Here's a simple one: reading a flattened graph from disk. If your flattened representation contains forward references, you have to fix them up in a strict language. In a lazy language, you can refer to elements you haven't yet read, eliminating that book-keeping.
That's a good point. Indeed, I had used laziness in a programme that read a file that contained a series of entity definitions that could include forward references, I just couldn't remember exactly how I'd used laziness. (-: (It's also useful in some memoising, I think.) -- Mark

Mark T.B. Carroll wrote:
Bryan O'Sullivan
writes: Mark T.B. Carroll wrote:
I'm afraid no examples come easily to mind, though. Here's a simple one: reading a flattened graph from disk. If your flattened representation contains forward references, you have to fix them up in a strict language. In a lazy language, you can refer to elements you haven't yet read, eliminating that book-keeping.
That's a good point. Indeed, I had used laziness in a programme that read a file that contained a series of entity definitions that could include forward references, I just couldn't remember exactly how I'd used laziness. (-: (It's also useful in some memoising, I think.)
-- Mark
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Near the bottom of http://www.haskell.org/hawiki/TyingTheKnot is an example that uses lazy evaluation to do exactly this. The real kicker though, is that the change from backward references only (i.e. simplistic one-pass code that would work in a strict language) to forward and backward references is trivial (just pass in the output).

Neil Mitchell wrote:
Things like laziness are cool, but are harder to convince a strict programmer that they are useful.
Strict programmers like the "yield" command too. The same behaviour can be obtained by laziness, with easier reasoning. That said, strict programmers may or may not like easier reasoning. Also, laziness in general (when not restricted to generators) is not easier to reason either.

G'day all.
Quoting Neil Mitchell
I think its important to cover whats different about Haskell. Things like laziness are cool, but are harder to convince a strict programmer that they are useful.
I think you could. What you need to convince a strict programmer of is that laziness gives you modularity. The Graham Hutton Sudoku solver is a nice example, but it'd be cool if we had a similar example that was less cheesy than Sudoku. A dynamic programming or memoing example might not hurt, either. Cheers, Andrew Bromage

G'day all. I wrote:
I think you could. What you need to convince a strict programmer of is that laziness gives you modularity. The Graham Hutton Sudoku solver is a nice example, but it'd be cool if we had a similar example that was less cheesy than Sudoku.
OK, it's not pretty, but this is diff(1) in 120 lines: http://andrew.bromage.org/darcs/diff/ It illustrates: - Lazy evaluation (dynamic programming, lazy I/O, infinite lists) - Function pipelining with (.) and ($) - Monads - Immutable arrays - List comprehensions - Algebraic data types - Type-safe type synonyms (newtype) - Fancy newtype deriving (Num) - Smart constructors - Pattern matching with at-patterns - Lambda expressions - Operator sections - More besides Cheers, Andrew Bromage

ajb@spamcop.net wrote:
OK, it's not pretty, but this is diff(1) in 120 lines:
(Btw, pairs (Int,Int) are members of the Ix class as well, so there is no need to generate an array of arrays. You can just pretend that one array is indexed by pair of Ints table = array ((0,0),(lxs-1,lys-1)) [((i,j), cell i j x y) | (i,x) <- zip [0..] xs, (j,y) <- zip [0..] ys] ) Regards, apfelmus

G'day all.
Quoting apfelmus
(Btw, pairs (Int,Int) are members of the Ix class as well, so there is no need to generate an array of arrays.
I know. It originally used lists, which is why it looks like that. I only allowed myself half an hour to write & debug this, so what you see is what you get. BTW, the fact that it's possible to write a working diff from scratch in half an hour and in only 100 or so lines is remarkable, I think. And it's the combination of all of those Haskell features that I mentioned which makes it possible. Cheers, Andrew Bromage

Hans van Thiel wrote:
On Mon, 2007-04-16 at 09:34 +0100, Simon Peyton-Jones wrote:
Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon
I'm really enthusiastic about parsec. Even though the principles are [cut] 4) there is a very helpful and knowledgeable community.
It is significant that Parsec has been and continues to be a lure of Haskell. Also, the community, in my opinion, is one of the greatest boons of the language, but I'm not sure how to convey that. This blog article (http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-str...) was/is fairly popular and demonstrates many aspects of Haskell and the way Haskellers think. Some of the recent ByteString stuff that does interesting things faster and much cleaner than C may also be a good example.

One technique I find compelling is (ab)using the type class system for
meta programming. Something from Lightweight Static Resources, Faking
It, or Hinze's Full Circle slides might be really attractive. Perhaps
Danvy's Haskell printf? The hook might be:
"Yeah, you've heard of strong static typing and polymorphism, but did
you know you could do this?"
Also: generic programming is always a hot topic.
On 4/16/07, Simon Peyton-Jones
Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Simon, Hopefully a video of this tutorial would be made available as a learning resource for those of use who can't make it to this Convention. Troy -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Simon Peyton-Jones Sent: Monday, April 16, 2007 4:34 AM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Tutorial on Haskell Friends I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/ I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics. One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were. So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out: Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10 But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author. Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done". Thanks! Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hopefully! Do suggest it to the OSCON organisers: the one I'm in touch with is Vee McMillen [vee.com@oreillynet.com] Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of | Taillefer, Troy (EXP) | Sent: 16 April 2007 15:08 | To: Simon Peyton-Jones; haskell-cafe@haskell.org | Subject: RE: [Haskell-cafe] Tutorial on Haskell | | Simon, | | Hopefully a video of this tutorial would be made available as a learning | resource for those of use who can't make it to this Convention. | | Troy | | | -----Original Message----- | From: haskell-cafe-bounces@haskell.org | [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Simon | Peyton-Jones | Sent: Monday, April 16, 2007 4:34 AM | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] Tutorial on Haskell | | Friends | | I have agreed to give a 3-hr tutorial on Haskell at the Open Source | Convention 2007 | http://conferences.oreillynet.com/os2007/ | | I'm quite excited about this: it is a great opportunity to expose | Haskell to a bunch of smart folk, many of whom won't know much about | Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll | be practitioners rather than pointy-headed academics. | | One possibility is to do a tutorial along the lines of "here's how to | reverse a list", "here's what a type is" etc; you know the kind of | thing. But instead, I'd prefer to show them programs that they might | consider *useful* rather than cute, and introduce the language along the | way, as it were. | | So this message is to ask you for your advice. Many of you are exactly | the kind of folk that come to OSCON --- except that you know Haskell. | So help me out: | | Suggest concrete examples of programs that are | * small | * useful | * demonstrate Haskell's power | * preferably something that might be a bit | tricky in another language | | For example, a possible unifying theme would be this: | http://haskell.org/haskellwiki/Simple_unix_tools | | Another might be Don's cpu-scaling example | http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10 | | But there must be lots of others. For example, there are lots in the | blog entries that Don collects for the Haskell Weekly Newsletter. But | I'd like to use you as a filter: tell me your favourites, the examples | you find compelling. (It doesn't have to be *your* program... a URL to | a great blog entry is just fine.) Of course I'll give credit to the | author. | | Remember, the goal is _not_ "explain monads". It's "Haskell is a great | way to Get The Job Done". | | Thanks! | | Simon | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe

Simon Peyton-Jones wrote:
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
[...]
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
While this it not a concrete suggestion for an example, I'd like to say why I can't help but program in Haskell: it gives me power. Programming in Haskell is like dual-wielding two light sabers whereas programming in imperative languages is like being equipped with a blunt kitchen knife. Sure, cleverly used, you can dissect problems with the knife but the light saber will disintegrate them instantly. If I were to give a tutorial, I would concentrate on showcasing such power. My current favorite example of power is the k-minima problem that has been discussed on this list: take k . quicksort Why is this program correct? Because it's almost the problem specification and because the type checker accepts it. But is it fast? Sure it is, because lazy evaluation does miracles (at least here ;). What else? The sugar on top is that this program is polymorphic. The above example is probably not considered "useful". To me, useful = asymptotically fast algorithm for a difficult problem, and I'm always astonished how incredibly easy it is to formulate or even derive a Haskell program that introduces the missing logarithm. But somehow, the word "performance" that people cry for doesn't seem to be related to that. At least, that's the impression I get when experiencing the sluggishness of certain programs. Anyway, maybe a showcase of power would be if the talk talks about how to create talks in Haskell, especially the talk being held. I mean that the showcased example could be to build a small type-setting/graphics/PS or PDF system in Haskell from scratch that is capable of producing the slides for the talk itself. This would include * a simple dynamic programming type-setting algorithm (performance) * a simple, preferably external (XMl, Parsec, ...) language for describing slides with some macro capabilities (like variables and substitution, perhaps even recursion or loops, slide numbers!) (expressiveness) * a small vector graphics library (for text and a few visual gimmicks) that can output to PDF (or PostScript for simplicity). (polymorphism: one API, different backends). The point is of course: "With Haskell, I'm not only able to create my slides from scratch, but I can even completely explain the code to you in only 3 hours!". Regards, apfelmus

I found this blog post, which describes a way to protect against "SQL injection" attacks using the type system, to be really enlightening. http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-str... Justin

Having just read Simon Marlow's paper on the Haskell Web Server, I think it might be interesting to at least mention it, and how simple it is, while still performing well. Also, I second the comment several have made so far that talking about concurrency is important. Haskell does it better than most languages, and people care about concurrency these days. Admittedly, these aren't very concrete suggestions. Aaron

Simon Peyton-Jones
My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
But there must be lots of others.
As one of those python/ruby types trying to learn Haskell for the past year, here are my suggestions for small examples: - Tom Moertel's Haskell Port Scanner Why? Demonstrates concurrent haskell in a small amount of lines http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haske... - A web-server example of some sort that interfaces with a database and uses some interesting HTML combinator library. - Building a simple unit testing framework is always a good example (even though they already exist), and then introducing quickcheck perhaps. - A program to concurrently verify the links on an HTML page recursively. I'm sure there are lots of interesting idioms and techniques that could be used while keeping the code small and elegant. - Perhaps a Haskell version of Norvig's 20-line Python Spell Checker: Why? Maybe a Haskell version could be shorter and more elegant? http://norvig.com/spell-correct.html - Tom Moertel's Directory Tree Printing in Haskell: Why? Demonstrates all sorts of introductory techniques http://blog.moertel.com/articles/2007/03/28/directory-tree-printing-in-haske... Some thoughts on other topics suggested by others: - Parsec is not that interesting for those coming from perl, ruby, or python as they rely on regular expressions for everything and just expect that they are part of the language. The thought of writing one's own parser is not as "cool" as most Haskellers believe it is, regardless of how interesting the parsec library is. - STM may be too complex of a subject for an intro to Haskell tutorial. There are just too many concepts in there that may overwhelm some beginners. - Don's post on shell scripting was very interesting, but I'm still having a hard time understanding some parts of it, the error handling part, and I've been playing with Haskell on and off for the past year (I'm also a slow learner and not an academic). - Don's post on simple UNIX utilities was also quite nice. I believe he also wrote a simple IRC bot example that would prove interesting, can't seem to find the link at the moment though. Just my thoughts as a newbie desiring a book on how to use Haskell in a practical manner (such as Practical Common Lisp book). -Pete

pete-expires-20070615:
Simon Peyton-Jones
writes: My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
But there must be lots of others.
As one of those python/ruby types trying to learn Haskell for the past year, here are my suggestions for small examples:
- Tom Moertel's Haskell Port Scanner Why? Demonstrates concurrent haskell in a small amount of lines http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haske...
- A web-server example of some sort that interfaces with a database and uses some interesting HTML combinator library.
- Building a simple unit testing framework is always a good example (even though they already exist), and then introducing quickcheck perhaps.
It's interesting to note that QuickCheck generalises unit testing: zero-arity QC properties are exactly unit tests.
- A program to concurrently verify the links on an HTML page recursively. I'm sure there are lots of interesting idioms and techniques that could be used while keeping the code small and elegant.
Ah, there's a (parallel) program I wrote for this, urlcheck. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/urlcheck-0.1 I had meant to use this as a basis for a blog article, but didn't get around to it.
- Perhaps a Haskell version of Norvig's 20-line Python Spell Checker: Why? Maybe a Haskell version could be shorter and more elegant? http://norvig.com/spell-correct.html
- Tom Moertel's Directory Tree Printing in Haskell: Why? Demonstrates all sorts of introductory techniques http://blog.moertel.com/articles/2007/03/28/directory-tree-printing-in-haske...
Some thoughts on other topics suggested by others:
- Parsec is not that interesting for those coming from perl, ruby, or python as they rely on regular expressions for everything and just expect that they are part of the language. The thought of writing one's own parser is not as "cool" as most Haskellers believe it is, regardless of how interesting the parsec library is.
That's a useful insight.
- STM may be too complex of a subject for an intro to Haskell tutorial. There are just too many concepts in there that may overwhelm some beginners.
- Don's post on shell scripting was very interesting, but I'm still having a hard time understanding some parts of it, the error handling part, and I've been playing with Haskell on and off for the past year (I'm also a slow learner and not an academic).
Interesting! Thanks for the feedback.
- Don's post on simple UNIX utilities was also quite nice. I believe he also wrote a simple IRC bot example that would prove interesting, can't seem to find the link at the moment though.
http://haskell.org/haskellwiki/Roll_your_own_IRC_bot
Just my thoughts as a newbie desiring a book on how to use Haskell in a practical manner (such as Practical Common Lisp book).
Don't we all! :-) -- Don

On Apr 16, 2007, at 9:29 PM, Donald Bruce Stewart wrote:
It's interesting to note that QuickCheck generalises unit testing: zero-arity QC properties are exactly unit tests.
I don't think this works very well. I rely quite heavily on being able to compare expected output with test results and QC does not seem to provide for this feature when tests are zero arity. Am I missing something? Thanks, Joel -- http://wagerlabs.com/

joelr1:
On Apr 16, 2007, at 9:29 PM, Donald Bruce Stewart wrote:
It's interesting to note that QuickCheck generalises unit testing: zero-arity QC properties are exactly unit tests.
I don't think this works very well. I rely quite heavily on being able to compare expected output with test results and QC does not seem to provide for this feature when tests are zero arity.
Am I missing something?
That's just the default driver. Plenty of custom drivers exist which compare the output. The QC driver is just a function you implement, after all. -- Don

Are there any examples of such custom drivers? On Apr 16, 2007, at 10:09 PM, Donald Bruce Stewart wrote:
That's just the default driver. Plenty of custom drivers exist which compare the output. The QC driver is just a function you implement, after all.

I usually roll a new driver for each project, for example: http://www.cse.unsw.edu.au/~dons/code/fps/tests/QuickCheckUtils.hs and a smp parallel driver, http://www.cse.unsw.edu.au/~dons/code/pqc/Test/QuickCheck/Parallel.hs There's a few examples in Test.QuickCheck too. joelr1:
Are there any examples of such custom drivers?
On Apr 16, 2007, at 10:09 PM, Donald Bruce Stewart wrote:
That's just the default driver. Plenty of custom drivers exist which compare the output. The QC driver is just a function you implement, after all.

Why can't you just do 'f 1 2 3 == (4, 5, 6, 7)' to test f? On Apr 16, 2007, at 22:08 , Joel Reymont wrote:
On Apr 16, 2007, at 9:29 PM, Donald Bruce Stewart wrote:
It's interesting to note that QuickCheck generalises unit testing: zero-arity QC properties are exactly unit tests.
I don't think this works very well. I rely quite heavily on being able to compare expected output with test results and QC does not seem to provide for this feature when tests are zero arity.
Am I missing something?
Thanks, Joel
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

That's what HUnit does but it's enticing to be able to standardize on QuickCheck for all of your testing. On Apr 16, 2007, at 10:11 PM, Lennart Augustsson wrote:
Why can't you just do 'f 1 2 3 == (4, 5, 6, 7)' to test f?

On Mon, 2007-04-16 at 22:17 +0100, Joel Reymont wrote:
On Apr 16, 2007, at 10:11 PM, Lennart Augustsson wrote:
Why can't you just do 'f 1 2 3 == (4, 5, 6, 7)' to test f?
That's what HUnit does but it's enticing to be able to standardize on QuickCheck for all of your testing.
Prelude Test.QuickCheck> let prop0 = List.sort [3,2,1] == [1,2,3] in quickCheck prop0 OK, passed 100 tests. -k

On Apr 17, 2007, at 9:31 AM, Ketil Malde wrote:
Prelude Test.QuickCheck> let prop0 = List.sort [3,2,1] == [1,2,3] in quickCheck prop0 OK, passed 100 tests.
My point is to be able to see that result generated was X and that it did not match expected Y, where both X and Y are printed out. -- http://wagerlabs.com/

- Parsec is not that interesting for those coming from perl, ruby, or python as they rely on regular expressions for everything and just expect that they are part of the language. The thought of writing one's own parser is not as "cool" as most Haskellers believe it is, regardless of how interesting the parsec library is.
I would think the reverse... people who have used regexes a lot might be interested in a technique that doesn't have their limitations. For example, you can define your own parsers (anyone who has had to deal with REs of any complexity will appreciate that), you can "remember" things (e.g. the classic eat chars until balancing paren thing), much better error reporting (wouldn't a perler like to know where and how his regex failed to match?) and then you're not limited to characters! I gave a talk on haskell once and intended to include (unfortunately ran out of time) a "write your own regexish language in 50 lines" section using parser combinators (a simplified monadic setup with regex style capturing groups). Then show how I can define custom parsers (e.g. match a number between x and y), recursive ones (match a sexpr), and wind up with much more readable individually testable expressions, e.g. "ip = let ipnum = group (num_in_range 0 255) in ipnum >> dot >> ipnum >> dot >> ipnum >> dot >> ipnum" then "log_msg = hostname >> ip >> blah" vs. the usual huge buggy regex. And then I can take the same operators and apply them to matching keywords to e.g. match cmdline args for a simple specification language. What you lose is the nice concise line-noise language, but then you can show how easy it is to write a line noise -> parser combinator converter. It illustrates a few nice things about haskell: laziness for the recursive defs and easy backtracking, low syntax overhead and custom operators for DSLs, composability, etc.

"Evan Laforge"
It illustrates a few nice things about haskell: laziness for the recursive defs and easy backtracking, low syntax overhead and custom operators for DSLs, composability, etc.
Although that is true, I somehow feel that showing a perl, ruby, or python programmer an alternate approach to regexps, a technique firmly ingrained into the roots of these languages, will not garner much interest in Haskell. I know this is the case for me. In fact, it was always a large negative for me that Haskell/GHC never had decent builtin support for regexps until recently (6.6). From a practical point of view, the tasks that I do frequently involve the use of regexps (for better or worse). Again, I'm not an academic, just an everyday python programmer trying to assist me in my day job. Upon thinking about this subject further, I think it would be very important that Simon somehow incorporates at least one use of the new regexp library. The target audience would by more likely to consider Haskell if it contains they're beloved tool of choice. Later, they can discover the elegance of parsec if needed. -Pete

On Tuesday 17 April 2007 10:30, Pete Kazmier wrote:
From a practical point of view, the tasks that I do frequently involve the use of regexps (for better or worse).
Likewise. It's true that when regexps are readily available, everything can look like a hammer; but sometimes a nail is just a nail. :-) Alexis.

On Tuesday 17 April 2007 14:48, Alexis Hazell wrote:
Likewise. It's true that when regexps are readily available, everything can look like a hammer; but sometimes a nail is just a nail. :-)
Er. i meant to say, when the regexp /hammer/ is readily available, everything can look like a /nail/. %-} A.

Simon Peyton-Jones
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
As for me I find quickCheck a killer feature, and quite concise. While on the subject, i'd like to mention that at last PLEAC now has a "standard" haskell version: http://pleac.sf.net/pleac_haskell of course, it's still a long way to go: only 9% is done, nice comments should be added, better code... But it's quite useful already! (i know pleac is somewhat a duplicate of http://haskell.org/haskellwiki/Cookbook, and it's not always adapted to haskell, but i still think it's quite useful and worth working on it. i suggest it's time to remove the pleac bashing from http://haskell.org/haskellwiki/Cookbook)

In my opinion, one of the things that makes Haskell difficult to learn is the value system. I'm not referring to "pure" vs. "impure". Instead, I am referring to the beliefs and principles held by the Haskell community that are not shared with most of the programming world. Principles like "It is valuable to be able to reason about programs rigorously". This is foreign to most developers. When they get to the section of a Haskell book that starts talking about this, their eyes glaze over and they skip over to the "more practical stuff". By the time they get to Monads they're ready to rip their eyes out because the book is "too theoretical" or "too academic". One of the truly powerful things about Haskell is the short distance between theory and practicality. The problem is how to demonstrate this convincingly. The ability to prove a program's correctness is regularly trotted out for show in this arena (or at least the lighter- weight claim that programs that compile usually work). I don't think that most developers (and certainly not the OSCON crowd) are ready to drink that kool-aid. They *enjoy* debugging and are tired of the "static" vs. "dynamic" debate. But the ability to reason about programs has borne fruit that I *do* think they will appreciate. Because many of them care about performance. I don't need to tell the subscribers to this list that the shockingly good performance of code written using Data.ByteString.Lazy is a direct result of being able to reason about programs. Obviously, the details of the fusion techniques are outside the scope of any introductory tutorial. But I think it would be useful to quickly implement a "wc -l" equivalent and explain why it's faster than the simple C equivalent. Nothing overly deep, just draw the line from "reasoning about programs" to "fusion" and on to "amazing performance" (capping it off with the fact the the fusion optimization is in the *Library*, not baked in to the compiler). At a minimum, it shows that being able to reason about programs rigorously can have a payoff in a currency that they value. R Hayes rfhayes<>@>reillyhayes.com On Apr 16, 2007, at 1:34 AM, Simon Peyton-Jones wrote:
Friends
I have agreed to give a 3-hr tutorial on Haskell at the Open Source Convention 2007 http://conferences.oreillynet.com/os2007/
I'm quite excited about this: it is a great opportunity to expose Haskell to a bunch of smart folk, many of whom won't know much about Haskell. My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics.
One possibility is to do a tutorial along the lines of "here's how to reverse a list", "here's what a type is" etc; you know the kind of thing. But instead, I'd prefer to show them programs that they might consider *useful* rather than cute, and introduce the language along the way, as it were.
So this message is to ask you for your advice. Many of you are exactly the kind of folk that come to OSCON --- except that you know Haskell. So help me out:
Suggest concrete examples of programs that are * small * useful * demonstrate Haskell's power * preferably something that might be a bit tricky in another language
For example, a possible unifying theme would be this: http://haskell.org/haskellwiki/Simple_unix_tools
Another might be Don's cpu-scaling example http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
But there must be lots of others. For example, there are lots in the blog entries that Don collects for the Haskell Weekly Newsletter. But I'd like to use you as a filter: tell me your favourites, the examples you find compelling. (It doesn't have to be *your* program... a URL to a great blog entry is just fine.) Of course I'll give credit to the author.
Remember, the goal is _not_ "explain monads". It's "Haskell is a great way to Get The Job Done".
Thanks!
Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

R Hayes wrote:
They *enjoy* debugging ...
I have to say this is one of the best things I've found for catching bad programmers during interviews, no matter what kind of system it is for. I learned this the hard way after watching someone who never really understood her program, but just kept thwacking at it with a debugger until it at least partially worked. Dave

On Apr 17, 2007, at 4:46 PM, David Brown wrote:
R Hayes wrote:
They *enjoy* debugging ...
I have to say this is one of the best things I've found for catching bad programmers during interviews, no matter what kind of system it is for. I learned this the hard way after watching someone who never really understood her program, but just kept thwacking at it with a debugger until it at least partially worked.
I've seen this too, but I would not use the word debugging to describe it. I don't think I agree that enjoying debugging is a sufficient symptom for diagnosing this condition. There are many people that love the puzzle-box aspect of debugging. Some of them are very talented developers. R Hayes rfhayes<>@>reillyhayes.com
Dave

R Hayes wrote:
On Apr 17, 2007, at 4:46 PM, David Brown wrote:
R Hayes wrote:
They *enjoy* debugging ...
I have to say this is one of the best things I've found for catching bad programmers during interviews, no matter what kind of system it is for. I learned this the hard way after watching someone who never really understood her program, but just kept thwacking at it with a debugger until it at least partially worked.
I've seen this too, but I would not use the word debugging to describe it. I don't think I agree that enjoying debugging is a sufficient symptom for diagnosing this condition. There are many people that love the puzzle-box aspect of debugging. Some of them are very talented developers.
R Hayes rfhayes<>@>reillyhayes.com
Dave
I agree with the latter sentiment. I call the "thwacking at it" approach "random programming" or "shotgun programming", the latter suggesting that it's like shooting at the problem randomly until it dies. I prefer not having to debug, but when I do have to I find it fun (up to a point). Mike

Yep - I've seen it in course work I've set in the past - random walk
through the arrangement of symbols in the language (it was a process
algebra work and proof system to check deadlock freedom).
... but ...
Haskell even helps those people - if you've created something that
works (and you are at least sensible to create a test suite be it
regression or property based) - then there is more confidence that
they've coded "a" solution (if not a good one).
Haskell raises the value of formality (both ecomomically and in terms
of its caché) - changin the mindset of the "masses" - creating the
meme - that's tricky. Especialy if they're really off the B Ark!
(http://www.bbc.co.uk/cult/hitchhikers/guide/golgafrincham.shtml)
Neil
On 18/04/07, Michael Vanier
R Hayes wrote:
On Apr 17, 2007, at 4:46 PM, David Brown wrote:
R Hayes wrote:
They *enjoy* debugging ...
I have to say this is one of the best things I've found for catching bad programmers during interviews, no matter what kind of system it is for. I learned this the hard way after watching someone who never really understood her program, but just kept thwacking at it with a debugger until it at least partially worked.
I've seen this too, but I would not use the word debugging to describe it. I don't think I agree that enjoying debugging is a sufficient symptom for diagnosing this condition. There are many people that love the puzzle-box aspect of debugging. Some of them are very talented developers.
R Hayes rfhayes<>@>reillyhayes.com
Dave
I agree with the latter sentiment. I call the "thwacking at it" approach "random programming" or "shotgun programming", the latter suggesting that it's like shooting at the problem randomly until it dies. I prefer not having to debug, but when I do have to I find it fun (up to a point).
Mike
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

As one who teaches programming in a lot of different languages, I can state unequivocally that strong static typing of the Haskell or Ocaml variety is (in addition to all its other benefits) a godsend to the instructor. So many incorrect ways of writing programs are simply ruled out right at the start that it makes it easier to concentrate on what really matters. The downside is that sometimes you get programmers from an imperative languages background who cannot figure out why some simple code is giving them a type error (for instance, by not putting in an "else" clause in an "if" statement). Mike Neil Davies wrote:
Yep - I've seen it in course work I've set in the past - random walk through the arrangement of symbols in the language (it was a process algebra work and proof system to check deadlock freedom).
... but ...
Haskell even helps those people - if you've created something that works (and you are at least sensible to create a test suite be it regression or property based) - then there is more confidence that they've coded "a" solution (if not a good one).
Haskell raises the value of formality (both ecomomically and in terms of its caché) - changin the mindset of the "masses" - creating the meme - that's tricky. Especialy if they're really off the B Ark! (http://www.bbc.co.uk/cult/hitchhikers/guide/golgafrincham.shtml)
Neil
On 18/04/07, Michael Vanier
wrote: R Hayes wrote:
On Apr 17, 2007, at 4:46 PM, David Brown wrote:
R Hayes wrote:
They *enjoy* debugging ...
I have to say this is one of the best things I've found for catching bad programmers during interviews, no matter what kind of system
it is
for. I learned this the hard way after watching someone who never really understood her program, but just kept thwacking at it with a debugger until it at least partially worked.
I've seen this too, but I would not use the word debugging to describe it. I don't think I agree that enjoying debugging is a sufficient symptom for diagnosing this condition. There are many people that love the puzzle-box aspect of debugging. Some of them are very talented developers.
R Hayes rfhayes<>@>reillyhayes.com
Dave
I agree with the latter sentiment. I call the "thwacking at it" approach "random programming" or "shotgun programming", the latter suggesting that it's like shooting at the problem randomly until it dies. I prefer not having to debug, but when I do have to I find it fun (up to a point).
Mike
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 18/04/07, R Hayes
One of the truly powerful things about Haskell is the short distance between theory and practicality. The problem is how to demonstrate this convincingly. The ability to prove a program's correctness is regularly trotted out for show in this arena (or at least the lighter-weight claim that programs that compile usually work). I don't think that most developers (and certainly not the OSCON crowd) are ready to drink that kool-aid. They *enjoy* debugging and are tired of the "static" vs. "dynamic" debate. But the ability to reason about programs has borne fruit that I *do* think they will appreciate. Because many of them care about performance.
I completely agree with you there. Someone earlier in the thread mentioned that QuickCheck almost in passing, but I think it should be emphasised: *QuickCheck is a really powerful way to work.* The real pain in the butt with unit tests is having to write the damn things. Especially for corner cases - if they were easy to reason about they wouldn't really be corner cases, would they? QC allows you to sidestep that neatly by generating a set of unit tests from a specification. And often generating cases you *wouldn't* have thought of yourself. Genius! It does rely on a functional mindset, however. No state-fiddling going on behind our backs. But maybe if you sell the idea first - create hundreds of unit tests on demand without lifting a finger - then people will make the leap of their own accord. Because let's face it, selling referential transparency is a pretty dead loss ;-) Salesmanship is about pointing out problems people have [1]. The problem R Hayes identifies here is that theory is great in theory, but in practise it's *too much work*. And short of creating a system where even your QC properties are auto-generated (I live in eternal hope...), this is a really important advances which people should learn more about. [1]: http://weblog.raganwald.com/2007/01/what-ive-learned-from-sales-part-i.html Cheers, Dougal.

Dougal Stanton wrote:
*QuickCheck is a really powerful way to work.*
The real pain in the butt with unit tests is having to write the damn things. Especially for corner cases - if they were easy to reason about they wouldn't really be corner cases, would they? QC allows you to sidestep that neatly by generating a set of unit tests from a specification. And often generating cases you *wouldn't* have thought of yourself. Genius!
For the regex-tdfa project, the unit tests from the AT&T site defined important semantic corners that some implementations got "wrong". Once I had code that worked with *all* those examples, the QuickCheck generated strings and regular expressions made for some quite weird random tests that still found holes in my code. And holes in the TRE c-library code. And holes in the standard c-library regex.h of OS X 10.4.x. So I am quite impressed by Quickcheck. -- Chris

Dougal Stanton wrote:
On 18/04/07, R Hayes
wrote: One of the truly powerful things about Haskell is the short distance between theory and practicality. The problem is how to demonstrate this convincingly. The ability to prove a program's correctness is regularly trotted out for show in this arena (or at least the lighter-weight claim that programs that compile usually work). I don't think that most developers (and certainly not the OSCON crowd) are ready to drink that kool-aid. They *enjoy* debugging and are tired of the "static" vs. "dynamic" debate. But the ability to reason about programs has borne fruit that I *do* think they will appreciate. Because many of them care about performance.
I completely agree with you there. Someone earlier in the thread mentioned that QuickCheck almost in passing, but I think it should be emphasised:
*QuickCheck is a really powerful way to work.*
Recently Neil Mitchell made an interesting blog post on this (http://neilmitchell.blogspot.com/2007/04/coding-nirvana.html).

I guess it is time to give my two cents on this topic I am definitely not an expert Haskell programmer I am a mere hobbyist I make my bread coding Java/C++/C. I think the two things I like most about Haskell are 1. Its methods of combination Lazy Eval, Function composition and Higher order functions aka the glue. Showing these off and how they compare and are better than many other languages would be a nice selling point. 2. Its type system and the kind of errors it eliminates, and the way it allows you to structure programs. Things I like least about Haskell (These are Haskell show stoppers for me) are 1. The tooling no good IDE for it. 2. The Libraries/Available Code Examples (Missing Functionality, Sparse availability, maturity, documentation, ability to understand them because many of them use Monads and Arrows, Functors etc). I have to strongly disagree with the statement that developers like to debug. Debugging is necessary because you can't reason about any "sizeable" piece of code just is not tractable even in Haskell. Now automated tools for reasoning about programs are very cool but lets face it no real world developer will sit down start to manually formally reason about large pieces of code. Picking Very Mathematical examples for the tutorial will also alienate typical developers. I am personal very interested in Category theory as it pertains to software engineering but it is not very accessible for someone who is trying to learn about it (aka me) never mind someone who could care less. Troy

On 4/18/07, Taillefer, Troy (EXP)
I have to strongly disagree with the statement that developers like to debug. Debugging is necessary because you can't reason about any "sizeable" piece of code just is not tractable even in Haskell. Now automated tools for reasoning about programs are very cool but lets face it no real world developer will sit down start to manually formally reason about large pieces of code.
I think the emphasis when mentioning "reasoning" really shouldn't be "you can reason formally about your programs and prove that they don't go wrong", nor "when it has gone wrong, you can reason about the program to figure out why", it should be "since the language doesn't do batshit insane things behind your back, your programs will mostly work the first time". The "reasoning" isn't an active task that you schedule time for, at least for a casual user like me, it's part of the actual programming. You do "reasoning" when writing in C++ as well, but you often get it wrong (because the language is, shall we say, unreasonable?) and that causes bugs. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

Here here.
This reminds me of a recent discussion on the cafe. Thee OP amounted
to: What are the monad laws good for?. The answer was: It means the
monad doesn't do surprising things and its behavior is congruent with
the basic intuitions of sequenced computation.
In my eyes, proving nice properties about programs and moreover
calculating the programs themselves are pillars of computer science.
However, I think it's helpful (for this sort of presentation crafting)
to be aware of the disparity between computer science and most
programming in the trenches. That said, Sylvan points out that the
disparity isn't a unbridgeable schism--it's just that the concepts
don't yet map as directly as we'd like.
On 4/18/07, Sebastian Sylvan
On 4/18/07, Taillefer, Troy (EXP)
wrote: I have to strongly disagree with the statement that developers like to debug. Debugging is necessary because you can't reason about any "sizeable" piece of code just is not tractable even in Haskell. Now automated tools for reasoning about programs are very cool but lets face it no real world developer will sit down start to manually formally reason about large pieces of code.
I think the emphasis when mentioning "reasoning" really shouldn't be "you can reason formally about your programs and prove that they don't go wrong", nor "when it has gone wrong, you can reason about the program to figure out why", it should be "since the language doesn't do batshit insane things behind your back, your programs will mostly work the first time". The "reasoning" isn't an active task that you schedule time for, at least for a casual user like me, it's part of the actual programming. You do "reasoning" when writing in C++ as well, but you often get it wrong (because the language is, shall we say, unreasonable?) and that causes bugs.
-- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I still love Haskell, but...
"since the language doesn't do batshit insane things behind your back"
- Hmmm... I'd contend that the Haskell language is the one language that
does the most "batshit insane things behind your back", for instance list
fusion. This is probably because there are many more "batshit insane
things" that can be done without playing russian-roulette games with your
semantics.
I believe that the problem is with the semantics: if all the relevant
semantics of your program are clear to you, then you understand it.
Otherwise, you don't. Regardless of language. C++ semantics are hard to
understand due to the existence of side effects, which explode the
dependencies between parts of the code to nuclear proportions. The
optional semantic notation "const" is the only tool available to help
diminish the problem. Haskell semantics are typically hard to understand
wherever strictness matters, which can also be very hard to figure out.
Optional strictness annotations are the tool there. Polymorphism problems
also come to mind, in which case type signatures are the tool. And
performance I always find hard to reason about in Haskell, and there is no
tool available besides the strictness annotations (or inline pragmas and
such). If it performs very well, because fusion happened or whatever, then
great. Otherwise, IO-izing is the only tool I know to apply to your code
to make it tractable for performance (so you can lay out your data in a
performant manner and such).
So Haskell semantics, in my experience, are sometimes just as obscure
and hard to understand as those of C++. Fortunately, that's a situation
that maybe changes to the language, or maybe more literature, can improve.
One example of a polymorphism semantic problem I encountered recently:
http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-str...
Nice article. Relevant and informative. My first thought was... how
silly. He's pairing up a type class with an abstract datatype (Language
and SafeString). That's a waste. He could have just used a type class
everywhere, and that would have worked fine. I hope you see that. Wherever
he uses SafeString he must, by necessity, add the Language context to its
parameter. So.. you can make SafeString a type class, with members
"empty", "frag"="litfrag", "text"="littext", "render"="natrep" and
"lang"="language", and the basic code turns much, much more concise. Users
of the library need to define "empty", whereas they didn't need to
previously, but that's a relatively small price to pay.
I tried that.
Then, when I saw the compiler errors, it downed on me.
The whole thing was done in this manner just so that he can instance
"Show (SafeString l)". Instancing "Show l" is not an option due to the way
class instantiation contexts are not part of the instance itself. Also, so
that he could define "showsPrec".
Therefore, with the new and improved SafeString I was trying to make,
there's more of a burden on the individual implementations of safe strings.
And all that was kinda hidden in the semantics, undocumented, and there
was no way for a strong novice like myself to figure it out without trying
the alternative, even though it is a small and simple example.
Maybe someone should properly document the class-record combo pattern
or something. Or maybe it is documented and I haven't seen it. :-)
JCAB
On Wed, 18 Apr 2007 10:50:04 -0700, Sebastian Sylvan
I think the emphasis when mentioning "reasoning" really shouldn't be "you can reason formally about your programs and prove that they don't go wrong", nor "when it has gone wrong, you can reason about the program to figure out why", it should be "since the language doesn't do batshit insane things behind your back, your programs will mostly work the first time". The "reasoning" isn't an active task that you schedule time for, at least for a casual user like me, it's part of the actual programming. You do "reasoning" when writing in C++ as well, but you often get it wrong (because the language is, shall we say, unreasonable?) and that causes bugs.

One of the truly powerful things about Haskell is the short distance between theory and practicality. [...] But the ability to reason about programs has borne fruit that I *do* think they will appreciate. Because many of them care about performance.
This is a topic I've been trying to learn more about. I appreciate that the language is pure, referentially transparent and that the semantics have even been formally spelled out. I like that there are tools like quickcheck that can be used to automate testing of formally stated properties. Now on to the next step... - extended static checking -- I'm aware of haskell ESC, but its not yet available. Are there any available tools for statically checking program properties (rather than testing for them)? - What about program proofs? Are there any systems that tie directly into haskell and let you augment your haskell program with a proof that can be machine checked? I know that some groups have taken haskell, translated to isabelle/hol and then done proofs in that system. I would love to be able to make a model (specification), prove some properties on it, create a real program based on the model, and by a combination of proof (when possible or convenient) and testing (when proofs become too cumbersome) assure myself that the program has the same properties or show equivalence to the model. I would love to be able to do all of this inside the haskell system (or at least in a system with minor extensions to haskell -- ie. proofs could be contained in comments).
R Hayes rfhayes<>@>reillyhayes.com
btw: semi related question -- are there any tools that can chase down the closure of all functions called by a program? Ideally showing it in graph form? ie. to track down all calls to "error" in a program. Tim Newsham http://www.thenewsh.com/~newsham/

Tim Newsham
- What about program proofs? Are there any systems that tie directly into haskell and let you augment your haskell program with a proof that can be machine checked?
Programatica. http://www.csee.ogi.edu/PacSoft/projects/programatica/ You can write properties in the PLogic specification language (in comments within your program), and have them translated to the Alfa/Agda theorem prover. (However, I haven't seen much development activity on the Programatica project for a couple of years now.) Regards, Malcolm
participants (48)
-
Aaron Tomb
-
ajb@spamcop.net
-
Albert Y. C. Lai
-
Alex Queiroz
-
Alexis Hazell
-
apfelmus
-
brad clawsie
-
Brandon Michael Moore
-
Brandon S. Allbery KF8NH
-
Bryan O'Sullivan
-
Bulat Ziganshin
-
Chris Kuklewicz
-
David Brown
-
Derek Elkins
-
dons@cse.unsw.edu.au
-
Dougal Stanton
-
Evan Laforge
-
Hans van Thiel
-
jerzy.karczmarczuk@info.unicaen.fr
-
jim burton
-
Joel Reymont
-
John Velman
-
Juan Carlos Arevalo Baeza
-
Justin Bailey
-
Ketil Malde
-
kynn
-
Lennart Augustsson
-
Malcolm Wallace
-
mark@ixod.org
-
Michael Vanier
-
Neil Davies
-
Neil Mitchell
-
Nicolas Frisby
-
Pete Kazmier
-
Pixel
-
R Hayes
-
riccardo cagnasso
-
Sebastian Sylvan
-
Simon Peyton-Jones
-
Stefan Monnier
-
Steffen Mazanek
-
Taillefer, Troy (EXP)
-
Thomas Conway
-
Thomas Hartman
-
Tim Newsham
-
Tomasz Zielonka
-
Udo Stenzel
-
Will Newton