As you may have noticed, lately, I’ve been fascinated by Haskell. I haven’t done anything much in it until quite recently; it’s been sitting in my to-do queue for a long time. This weekend, I was hacking away on a Haskell implementation of an interesting (but currently unimplemented) language from the Esolang wiki. For the most part, it went astonishingly smoothly, until I got to the point of putting things together, when I ran into a problem combining two monads, which is one of the typically difficult problems in real Haskell programming.

What surprised me a bit when I hit this is how hard it is to find an approachable source for the more advanced issues. If it’s hard on a language geek like me, it’s bound to be as bad or worse for a lot of other

people who might be interested in Haskell.

So the thought hit me. If enough readers are interested, I can write an intermittent series of articles

to teach Haskell, starting from the very early basics, all the way through to the messiest issues of monad transformers.

Are you interested? Interested enough that you’d be willing to accept a bit of a slowdown of the (already slow) topology posts to give me time to write it?

Let me know what you think, either in the comments below, or through email to markcc@gmail.com.

*Ok, folks, I get the hint, you can stop emailing me! :-)*

*Since posting the question on a holiday weekend saturday night, I’ve gotten 50 responses, and they’re unanimously in favor. I **will** start working on it, and the first parts should appear on the blog later this week.*

### Like this:

Like Loading...

SimonI’d be interested in reading your tutorial. Not that I’m likely to program in Haskell, but I think exposure to other programmings paradigms is essential.

I’d also be interested to know what you make of F#.

malpollyonCount me in. I’d love to see a good Haskell tutorial that goes from the basics up to monads.

DavidI know absolutely nothing about Haskell, but I’d love to learn. I’ve been a regular reader since before the SB move, and I’d love to learn Haskell from you. You have a knack for explaining complex things in an accessible way.

JakeI’m a regular reader, and would be very interested in a Haskell series. I’m keeping my fingers crossed that you get enough votes to do it!

Mark VandeWetteringI’d love to see a tutorial on Haskell programming. It seems kind of annoying to me that most of the programs that you see in Haskell are examples of programs that functional programming proponents use as illustrative of functional style rather than programs that people write to solve particular problems or needs. I look forward to seeing your attempt.

Eric WallaceI’d also be interested in this.

I second MarkV’s complaint about typical functional language tutorials. I

don’tneed to write a fibonacci number generator. Idoneed to write programs that process input, produce output, and occasionally do things in order with error handling, and it seems I have to have a read to Chapter 28 in a Haskell book and earn a degree in category theory to learn how to do it.AlexYes, I’d love to learn Haskell.

Michael ChermsideI’d be quite interested in a Haskell intro. I’d like to chime in and agree that I see tutorials that show trivial programs, and I see essays on Monads (which I really still don’t get), but I don’t see anything in between, and no tutorials USING monads, just defining them.

BrettI’d love it if you started from the basics. Like… even for people like me who haven’t ever really used a functional language.

donsFor those interested in getting started immediately, there’s a large collection of tutorials here:

* http://darcs.haskell.org/yaht/yaht.pdf (Recommended intro)

* http://en.wikibooks.org/wiki/Haskell (Haskell wikibook)

* http://research.microsoft.com/%7Esimonpj/Papers/marktoberdorf (Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign language calls) — a classic text

* http://haskell.org/haskellwiki/Roll_your_own_IRC_bot (A monadic irc bot in a few lines)

* http://haskell.org/haskellwiki/Category:Tutorials (Haskell wiki articles)

* http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html (Good introduction to monads)

* http://uebb.cs.tu-berlin.de/~magr/pub/Transformers.en.html (Good introduction to combining monads)

And of course more and more at http://haskell.org. Feel free to drop by the #haskell irc channel at http://haskell.org/haskellwiki/IRC_channel if you like.

Cale GibbardI’d be interested in seeing it. Also, if you haven’t done so already, please come and join us on IRC! irc.freenode.net #haskell

I’d also be willing to help answer any questions you might have (though you’ll also find me on the IRC channel, along with lots of others who like helping out and are probably more qualified than me much of the time).

As for combining monads, the best way to do this which is currently known about is to use monad transformers to build up the monad you’re interested in, or one which is a little more general, and then to newtype that and use the newtype-deriving feature to derive instances of Functor, Monad, and any other classes which you want to come straight through. You can also then implement any additional functionality while hiding some of the more general operations (which gives you the ability to do things like consistency checking). It also helps save a lot of lifting operations which you’d have if you used the monad transformers directly. You then write a run-function for your given monad, and wrap the whole thing up in a module and don’t export the data constructor for your newtype.

I intend to write a proper tutorial on that process, but if that made any sense at all, perhaps see if it works out in your particular example. Monads are really embedded domain specific languages, and the idea is you’re not so much combining them as constructing one with the particular features that you’re interested in.

One thing in which you might be interested is my Sudoku solver (which was written less as an example of how to solve Sudoku and more as an example of how to construct a monad), which is available at the top of http://www.haskell.org/haskellwiki/Sudoku . The overall structure of it is just what I described above.

Anyway, glad to hear about more people joining into the fun of using Haskell, and I hope to see you around!

Daniel MartinCount me in too – I’ve been looking for a more advanced source of practical information than what I can occasionally get from asking around #haskell.

Specifically, I’d be interested in an introduction to Parsec. I’ve written something to parse a tiny language in Haskell (for a Turing machine simulator), but have never touched Parsec, let alone played around with it enough to figure out how it works.

Finally, I would like to see something connecting Haskell’s concept of a Monad to your category theory bits from a few months ago. I still don’t understand what a category theory monad is; however, I do understand what a Monad is in Haskell and so I would appreciate the connection. (Of course, I’ll probably still not get anywhere until I re-read the category theory posts enough times to convince myself that there’s something there to begin with)

IvarsI’d be interested in the series, especially in it’s parts concerning advanced monad programming. It could also be another place to point my friends who are interested in haskell.

P.S. I really enjoy your blog.

KorayDan Piponi has some excellent articles on Haskell monads (and other math stuff) at http://sigfpe.blogspot.com/

Slawek K.I think it’s a great idea. I am learning Haskell and I would be very interested in reading a tutorial titled “Haskell for former mathematicians who don’t know category theory”.

One great introductory article about monads takes the following approach: present a problem, then an naive solution an average person would come up with, then the real solution based on the full power and support of the language. I think this technique is very effective, especially for self-learners.

As for getting to practical applications soon, for most people this means doing IO, GUI and in general interaction with the Real World. I think the very nature of Haskell makes this an advanced topic and there is no way around it. I would be happy to find out I am wrong on that.

Capt. Jean-Luc PikachuI too would be interested in whatever you have to say about Haskell…

Chad GroftCount me in as well. I have a textbook here I keep meaning to get to, but in the meantime…

vinceYess! I have even searched a couple of times the posts you wrote on Haskell just because they cleared up a few issues I had slight problems with. Great idea.

John ArmstrongWhile I find the topology interesting, I know topology. I don’t know Haskell. Do the tutorial.

John ArmstrongSlawek K.: what about “Haskell forcurrentmathematicians whodoknow category theory”? My interest in Haskell (and possibly that of others here) stems almost entirely from my interest in monoidally closed categories as a model of computation.Jonathan Vos PostMy son enjoys programming in Haskell. Is it the right language to answer a question by Franklin T. Adams-Watters about enumerating categories, namely:

“how many [concrete] categories are there with n morphisms and k [structureless] objects?

This table starts:

1

2 1

7 3 1

35 16 3 1

The first column is A058129, the number of monoids; the main diagonal is all 1’s…”?

There’s some argument about this in another web venue. I’ve provided an enumeration of the subset of directed graphs which can have loops and represent endofunctions which are “prime” (meaning neither the union of other prime endofunctions nor their categorical product).

But some who know Category Theory far better than I say it’s a hard enumeration.

It seems that Haskell has the right semantics and metalanguage and syntax to do this in a fairly straightforward way. A good answer here gets passed on to Franklin T. Adams-Watters and probably cites you by name and email address in that other venue.

Kristjan WagerCould be nice to see – the only functional programming language, I have worked with, is Standard ML, so it would be interesting to learn about Haskell.

Vishnu VyasYeah.. sure count me in too..

LinusHaskell is a lovely langauge, a shame that it is not more widely used. So yeah, a blog tutorial on it would be great, perhaps that can widen the userbase a bit.

Mikael JohanssonI’m with John Armstrong on this: I got sucked into the haskell community by reading Dan Piponi’s blog articles; and what really, really catches my eye is the importance of category theory for the language.

And one of the things I’ve been really missing since I started reading up on it was the language explained to someone who’s already reasonably fluent in category theory.

Gerald SquelartIt’s your fault that I fell in love with Haskell (from your Scheme vs. Haskell post a few weeks ago), so I’d dig(g) any more knowledge you’d care to share about it. 🙂

Thanks in advance.

Curt SampsonYes, I’d love to see articles and tutorials on Haskell here.

BrianI am interested in learning haskell I would definetly read your tutorial posts.

though I have to admit topology is more interesting, but I find it much easier to learn programming languages from blogs than hardcore math. So overall I would definetly find a Haskell blog tutorial more valuable than a topology articles.

DominikusHI’m very much interested in a series teaching Haskell — you seem to be a very good teacher, so I suppose that I will learn something from you. What I’m specifically interested in is how I can use Haskell as a vehicle for implementing a interpreter for Category Theory. Or: How close is Haskell in being a pure CT programming language?

Reinier PostI’d like to start a toy project in a functional language, and I’m wondering which language to pick. At the moment I’d rather try F#, which provides access to all the existing .NET libraries, than Haskell, for which I have no idea how to do a desktop GUI, a Web interface, socket-based networking, XML reading and writing, or other standard stuff that I may need in the project at some point.

So my questions to you:

– does Haskell have well-developed libraries for networking, HTML and XML processing, database access, and desktop GUIs?

– where does Haskell shine, compared to other functional languages, such as F#?

Reinier PostPS the toy project I have in mind is a system for playing board games. A game engine controls the game state and the possible moves; clients connect to the game engine to see the game state and execute moves. Version 0.1 would be a tic-tac-toe engine with 1 human player (using a command line interface) and 1 automatic player.

DannoI hope your Monad explanation is good. I’ve read a half dozen introductions to them and I almost always get lost.

Usually, the Maybe example makes sense, but then they go on to something a little more advanced and I end up somewhere in Siberia.