views:

6955

answers:

5

I am looking into F# and have read a few "Hello World!" intros that shows off the very basic syntax of the language. I am now ready to move on and try more advanced features, ie. functional programming styles. So my question is: What is your favorite advanced level tutorial on F#. I am not interested in basic introductions!

+3  A: 

I think Dustin Campbell's Project Euler series is a good place to start...

kobusb
+2  A: 

Would you consider some Tree and Graph algorithms? This is what I did for ocaml:

  • graph/digraph data types with functions to convert to graphviz. Also algorithms for dijkstra, if a graph is connected et cetera.
  • tree data type with operations for reading from text and converting to graphviz
  • next convert these to higher types --modules and functors. And try to generalize all these functions --graph and digraph have the same signature, and using abstract types for the edge/node data.
  • create an unrooted-tree (in a graph with phantom types), and functions to convert between graphs and trees given a root.
  • create a DAG (directed acyclic graph) using phantom types

This will help you to start building a library of helpful functions that you've consistently used and put them in a utility file. Don't worry that the type of your tree/graph is sub-optimal --play around with it, you'll see it very easy to change things around! I.E., Should you use Sets/Maps/Hashtbls or a more functional data structure as it's type? Why not both or all thirty! -- I like the hashtable solution for edges in ocaml since one key can store multiple results).

With all this you should have an excellent functional programming stylistic grasp on types, recursion, functors, modules, higher-order-functions, abstract types, phantom types, algorithms in functional languages, curried functions et cetera! And you're creating a suite of files that you can easily break out to do a ton of tasks --project euler or whatever. As time goes by you'll replace functions in your library with external ones and/or smaller functions and new data types...

I don't mean to throw a homework assignment at you, this is what I did since I encountered so many instances where I needed a graph/tree to visualize algorithms or to confirm my algorithms -- I ended up writing functions to draw in openGL as well since creating animated GIFs through C function calls wasn't portable enough for me.

anyway, good luck and let us know what you chose!

nlucaroni
+5  A: 

Currently I'm following a book in progress called 'Real World Functional Programming in .NET' with examples in F# and C# and consider it as a long term tutorial in F#. Since it is in the process of being written it makes it more exciting to follow because you can also give some feedback on it. The book is being written by Tomas Petricek.

Michiel Borkent
thanks a lot for the link :-)
ila
+7  A: 

F# for Scientists by Jon Harrop has proved useful. Lots of advanced worked examples.

I second that. Jon has a great teaching style. I thought I was past the "Hello World" stage, as in the question, and then read chapter's 1 and 2, (ie. the introduction) and found a wealth of information, in just 60 pages, that I'd missed from the beginner tutorials. Then the book starts to tackle the interesting, real world programs, and has a constant emphasis on teaching good functional style, as requested.
Javaman59
+9  A: 

I thought these few were good:

  1. Brian McNamara's posts on catamorphism.
  2. Don Syme's post on computation expressions.
  3. Harry Pierson's posts on monads.

And yes, +1 for Dustin Campbell's Project Euler.

fung