This Hands-On Lab is comprised by the following exercises. Examine the basic F# types including tuples and functions. Discover how the "let" keyword allows values to be bound to identifiers. See that in F# functions are the same as any other value, and are handled the same way. Demonstrate how this allows advanced language features such as partially-applied or "curried" functions. Discover how F# lists are built and the power that can be achieved by F#'s "Head + Tail" approach. Demonstrate the powerful pattern matching and recursion capabilities of F#. Demonstrate the power and usefulness of discriminated unions in F#.
F# is a new functional programming language from Microsoft. While it is primarily a functional programming language, it is known as a multi-paradigm language because it also supports object-oriented programming. F#’s tight integration with the entire .NET system of libraries and development environment enables developers to bring the power of Functional Programming to the .NET platform.
In this Hands-On Lab, you will learn how to:
- Use F# Types
- Leverage the let keyword to bind values to identifiers
- Use functions in F#
- Use lists in F#
- Leverage Pattern Matching and Recursion
- Create your own types and consume discriminated unions
You must have the following items to complete this lab:
- Microsoft Visual Studio 2010
All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps.
Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.
The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).
For convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The Dependencies.dep
file launches the Visual Studio installer file that installs the code snippets.
This Hands-On Lab is comprised of the following exercises:
- Examine the basic F# types including tuples and functions
- Discover how the let keyword allows values to be bound to identifiers
- See that in F# functions are the same as any other value and are handled the same way. Demonstrate how this allows advanced language features such as partially-applied functions (also known as “curried” functions).
- Discover how F# lists are built and explore the power that can be achieved by F#’s “Head + Tail” approach
- Demonstrate the powerful pattern matching and recursion capabilities of F#
- Demonstrate the usefulness of discriminated unions in F#
Estimated time to complete this lab: 60 minutes.
Exercise 1: Types in F#