Links to Online Material

The printed book references resources that are available online on the book web site. On this page you'll find links to the online materials mentioned in the book organized by chapters, so you can easily find the content you're looking for. I'll be adding most of the articles as the time permits, so please have patience!

  • Chapter 7: Writing operations for working with documents

    A few ideas that you can use to exercise implementing and using higher-order functions that work with a hierarchical data-structure representing documents.

    • You can use mapDocument to split text parts with more than 500 characters into two columns.
    • You can use aggregation to collect a list of images used in the document.
    • You can implement a filter-like operation that takes a function of type (DocumentPart -> bool) and creates a document containing only parts for which the function returns true. Using this function, you can remove all the images from a document.

    More information comming soon...

  • Chapter 7: Object-oriented representations

    This section assumes that you know a bit about some of the design patterns. You can find links to introductory articles on the book’s website. I'll be adding more information in the future. For now, you can start with the articles about design patterns at WikiPedia.

  • Chapter 7: Active patterns

    F# has an advanced feature called active patterns that allows us to encapsulate the composition to some extent. This enables us to publicly expose the composition, but not the whole discriminated union type, which can be useful for evolving F# libraries. There is a good overview about active patterns by Robert Pickering and also by Chris Smith. More details can be found in the MSDN documentation for F#. I also wrote an article about active patterns (and other meta-programming related features), which can be found here.

  • Chapter 8: Reflection

    One frequent requirement for behavior-centric programs is the ability to load new behaviors dynamically from a library. This can be done using the standard .NET classes from the System.Reflection namespace. The typical scenario is to load an assembly dynamically, find all appropriate classes inside the assembly, and create their instances at runtime.

    More information comming soon...

  • Chapter 9: Class declarations

    In the book, we use only a couple of most important object-oriented features of F#. However, F# supports many other constructs that are not discussed in the book including implementation inheritance and virtual methods, overloaded constructors etc.

    More information comming soon...

  • Chapter 11: Photo browser application in C#

    The C# version of the application is available as part of the downloadable source code from:

  • Chapter 12: F# quotations

    F# quotations are introduced in my article about meta-programming features of F#. There are also some information in an article, which discusses how to use F# quotations to write data-parallel programs and execute them on GPU.

    More information comming soon...

  • Chapter 12: Using infinite sequences to plot graphs

    The C# version of the application is available as part of the downloadable source code from:

  • Chapter 12: Computation builder for lazy values

    There’s a close relationship between computation expressions and laziness. It’s possible to create a computation expression that turns code into a lazily evaluated version, with a computation type of Lazy<'T>. You can try implementing the computation on your own: the only difficult part is writing the Bind member.

    More information comming soon...

  • Chapter 13: The World Bank data

    Currently, you need to run the first part of the F# script to download the data directly from the Word Bank.

    More information comming soon...

  • Chapter 13: Visualizing data using .NET 4.0 controls

    The .NET Framework 4.0 (a version that matches Visual Studio 2010) includes a new library for drawing charts that can be used in Windows Forms, server-side Web applications and also Silverlight. The library is fully managed, so it can be used directly from F# as any other .NET library. If you need to display charts in your standalone F# applications, this library is definitely worth a look.

    More information comming soon...

  • Chapter 14: The Parallel module and 'pseq' computation builder

    These components are currently available as part of the downloadable source code:

  • Chapter 15: Animations with units of measure

    In this chapter, we’re storing a time in behaviors as a value of type float32. The reason is that we’ll use behaviors primarily with graphics, and the System.Drawing namespace uses this numeric type. There are other options as well. Most interestingly, we could use units of measure and store the time as float<s> representing time in seconds. Units of measure would make the code more self-explanatory. We could define a pixel unit (px) and represent locations as float<px>

    More information comming soon...

  • Chapter 15: Behaviors and LINQ

    The signature of the Select method in listing 15.11 has the same structure as the Select method used in LINQ when writing queries. This isn’t accidental, and it means you can use C# query expressions to create behaviors. Here’s another way of creating the squaring behavior:

    var squared = from t in Time.Current select t * t;

    This means the same thing as the earlier version: the compiler translates the query expression into the same code. This type of query is interesting because the source of the values (Time.Wiggle) effectively contains a potentially infinite set of values. The “query” is only evaluated when we need a value from the new behavior for a specific time. We won’t discuss LINQ queries for behaviors in any more detail here, but we could also implement the SelectMany query operator, which would allow us to combine behaviors like this:

    var added = from a in Time.Current
            from b in Time.Wiggle
            select a + b;

    This is definitely an interesting alternative to using lifting explicitly. In F#, we could implement a computation expression builder too.

    More information comming soon...

  • Chapter 16: Online version of rectangle drawing

    In that version we make the application online and allow multiple users to connect to a single server and collaborate on drawing a single image. In that case, the state can be modified by the user, but also concurrently by a message coming from a network communication. If we decided to use mutable state, we’d have to carefully use locking, which would complicate the code. When we store the state using the technique we’ll introduce in this section we won’t have to do a single change—the code as we’ll write it is perfectly thread-safe, which is quite important nowadays.

    More information comming soon...