Mike Falanga speaks about Discriminated Unions at Cleveland F# SIG

I was able to record the Cleveland F# SIG, where Mike Falanga spoke about F# language’s Discriminated Unions feature (http://msdn.microsoft.com/en-us/library/dd233226.aspx).

Here are the videos I took of the event for all attendees that weren’t able to make it:

Mike started by describing Discriminated Unions by explaining the syntax for the type which looks like this:

type<type-name> =

| <case1-name> [of <data-type>]

| <case2-name> [of <data-type>]

Next followed a demo where he described a type Shape, which had a union of Square, Rectangle and Circle. Then a function was written that would allow us to calculate the various shape’s area.

Mike threw in a trick question too: “Why is there a period in front of integers in Rectangle(5., 3.)”

I’ll leave it up to the viewers to find out why..

Mike then:

  • explained the two types of Algebraic types: Product types and Sum Types.
  • compared how this feature compares with object orientation
  • explained idea of polymorphism in this context, as well as the open-closed principle
  • Comparative programming with C# followed right afterwards, demonstrating how more functionality can be added to either implementations
  • Showed the group an example from F# Deep Dives which succinctly implemented a Markdown Document
  • Showed the group an example from F# for fun and profit that validated an email address

I am very glad I attended as I met Ed from Rockwell Automation and the group chose to write some software to parse its huge amounts of plain text data!

As I receive Mike’s slides he used, I will update my post here.

Here are a few important links that were mentioned in the talk:

Few resources from the internet about F#:

  • Visual Studio’s Uservoice account: http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30935-languages-f-
  • F# on Github: http://fsharp.github.com/

I’d like to Microsoft for sponsoring this event. Looking forward to the next one I can attend!


One thought on “Mike Falanga speaks about Discriminated Unions at Cleveland F# SIG

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s