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:
| <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..
- 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:
- F# For Fun and Profit: http://fsharpforfunandprofit.com/
- F# Deep Dives, MEAP book at Manning: http://www.manning.com/petricek2/
- Event page at Bennett Adelson: http://www.bennettadelson.com/EventDetails.aspx?ID=91f8dc29-d48f-e211-8b4a-78e3b5102ea7
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!