F# Webcast (II.) - Using .NET libraries
About a week ago I posted the first part of my F# webcast series. It focused on explainining the basic ideas behind functional programming such as immutability, recursion and passing functions as arguments to other functions (or methods in C#). In the first part, we've seen some C# code to demonstrate the ideas and also a bit of F#, mainly to show the basic language features.
The second part is going to be exclusively about F#. It'll demonstrate how we can start writing
a demo application that grabs data from RSS feeds and processes them. You'll learn how to access
.NET libraries from F# (in particular, we'll use System.Net and System.Xml).
We'll develop the code iteratively, which means that we'll start by simply enumerating the RSS elements using for loop and printing the results and then we'll refactor the code to use tuples and sequence expressions to turn it into processing code that generates a sequence of feed items. Finally we'll also demonstrate how to use some of the functions from the previous part such as List.filter in practice.
F# Webcast Series
This webcast series follows the usual F# development process where you start with experimenting and writing an initial version of the solution interactively using the F# interactive tool. In the later phase of the process, we modify the code to make it parallel and asynchronous and finally, we can also encapsulate it into a standard .NET library that's usable from C#. Here is a list of all webcasts in the series:
- Part I. - Introducing functional concepts
The first part introduces functional programming principles such as immutability, recursion and functions that take other functions as parameter (higher order functions). This can all be demonstrated in C# 3.0, so we start with C# and then look how the same concepts look in F#. Finally, the first part also shows functions for working with lists in F#. - Part II. - Using standard .NET libraries
The second part demonstrates how we can use standard .NET libraries. It uses classes fromSystem.NetandSystem.Xmlto download content of a web page (RSS feed), load it into XML document and process it to find only posts that contain some specified keyword. - Part III. - Downloading web pages asynchronously
The third part shows how to make the code from the part II. better. It introduces F# asynchronous workflows that can be used for writing code that doesn't block a thread when waiting for the completion of some I/O request. This part also shows how to modify the code to download and process multiple feeds in parallel. - Part IV. - Developing standard .NET libraries
In the fourth part, we look how to encapsulate the functionality written in F# into classes. We'll finally create a project (rather than just use F# scripts) and we'll wrap the code we wrote into a .NET class. We'll also look how to compile the project into DLL and how to use it from a simple C# web application.
Downloads
- Source code from the webcast (F# Script)
- Download the video (WMV format, 17.6MB)
- Microsoft Visual Studio 2010 First Look [^] - Microsoft.Com
- Visual Studio 2010 Beta1 with F# is now available, plus matching F# CTP Update for VS2008 [^] - Don Syme's WebLog
- F# May CTP for Visual Studio 2008 [^] - Microsoft Downloads
Published: June 1, 2009 14:57
Tags: F# and MSR | Functional Programming in .NET
Share a link:
Facebook
- RE: F# Webcast: Using .NET libraries by Brennan Falkner (6/1/2009 9:58:08 PM)
Great stuff. I've been reading your articles since I started with F# about a year ago, and they've been a big help but these videos would have been great to have at the time. I'm really looking forward to Part IV as I've been struggling with how to best use F# to a large extent in a WPF project and the language interoperability has been a bit of a headache at times.


