Saturday, December 01, 2012

Introduction to stateful monads

I went to my first Zurich FSharp meeting the other day and made a presentation on how to program with state monads in F#.

The presentation is designed to pull you off the ground, to a higher order programming style, using the state and maybe monad as stepping stones. It finishes with stateful lifting.

Here is a link to a slightly improved version: youtube .

Link to sources are below but I would recommend that if you really do not know this type of programming and want to learn, then you should type it back in and allow yourself some creative liberty. This is usually a much better way to learn, than to just copy code!

You can watch it here if you want:

http://files.meetup.com/2794852/ModularStateMonadsInFSharp.pdf
http://files.meetup.com/2794852/XState1.fs
http://files.meetup.com/2794852/XState2.fs
http://files.meetup.com/2794852/Script.fsx



2 comments:

Ville Nurmi said...

I want to say thanks for your presentation. I read the PDF, watched the video and worked on the code for several hours, typing it "in my own words" and trying out alternative ways. After all this I feel that I am finally comfortable enough with monads in order to use them in my own code.

I'm quite new to functional programming and I've been learning about monads for a while from various sources. What was really helpful in your presentation was how you built your way to the monad starting from simple imperative code. Also lifting the state monad to apply to a part of a complex structure was exactly what I wanted to know about practical use of the state monad.

So thanks once again, this has been really helpful!

James Litsios said...

Thank Ville,
Giving that presentation was a little bit like making an airplane take off, and just let it go higher and higher, and although I could see that I lost some of public, it was still a very exciting thing to do. Finishing with the lifting felt a little bit like overdoing it, but I have seen so many monadic state example never get past a "flatworld" view of state. I really wanted to to leave my audience with the path to go past that "limited" view.

Thanks again, comments like that are always a pleasure!