Skip to content

don syme

These are the stories that have been posted to the don syme category.

Discoveries This Week 04/03/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich April 05, 2009 01:42

With the start of our F# User’s Group this next Monday and New England Code Camp 11 last weekend, things have been extremely busy this past week.  Meanwhile, the F# sociocosm is growing at a rapid pace.  This week we have a talk by Don Syme, a look at F# quotations, and finally, some discussion on Seq.unfold.

 

Chris Bowen’s Post, Announcing F# User Group in Cambridge - April 6

A shameless plug here for our new user group.  A big thanks to Chris for helping us find the resources we needed to start out.  Without him this might never have come together.

 

Don Syme’s Talk, F# and functional programming in .NET

As Don Syme is the father of F#, when he speaks the community listens.  In this talk Don focuses on the pleasure and speed inherent in using FP and F#.  He does this by describing the functional methodology and constructs which provide a simpler and more elegant model for building programs.

 

Alex P’s Post, F# quotations at their simplest

A simple example on the surface for sure.  However, if you haven’t seen the power of F#’s language oriented programming features this is sure to be of interest.

For a deeper look at the power of quotations check out Tomáš Petříček’s F# quotations visualizer.  If his past projects are any indication Tom’s upcoming book is a must have for any F# enthusiast.  I preordered a copy just today.

 

Martin Peck’s Post, Solving Problems in C# and F# - Part 2 
(and update)

One of the most fantastic things F# has to offer is the rich functional programming heritage of sequence operations.  To demonstrate how elegant they can make your code, I would like to offer the following alternative F# solution:

let fibs = 
  Seq.unfold (fun (a, b) -> Some( a, (b, a+b) )) (0I, 1I)
Seq.find (fun n -> n >= 10I ** 999I ) fibs

I’m going to take this opportunity to point out the obvious: we have here two lines of F# which does almost exactly the same thing as thirty six of C#.   Now that’s what I call power and elegance.  The unfold function pretty much does exactly what yield was doing before, but implicitly in terms of the unfold function.  The idea of unfold can be confounding at first and so here is a breakdown of how it works:

let fibs =
  Seq.unfold 
    (fun (a, b) -> //generator function, 
//
(a, b) is the previous state Some //Option monad, needed for unfold (a, (b, a + b))) //returned tuple: (value, state)
//or (
first, (second, third)) (0I, 1I) //Initial function state (first, second)

Note that in this version the state of the next two values in the sequence are always pre-calculated.  However, it is easy to avoid this if you instead consider the state in terms of the previous two values: 

let fibs = 
  Seq.unfold (fun (l, l2) -> 
    let n = l + l2 in Some( n, ( n, l ) ))
    (0I, 1I) //(previous, second previous)

If you want to learn more about unfold I recommend checking out:

 

Dustin Campell’s Post, Apples and Oranges

This is the best description of how unfold works I’ve seen to date. 

 
 

Functional Discoveries in the Microsoft Sociocosm 02/20/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich February 20, 2009 17:41

This week we have practical examples of Lazy Evaluation with Memoization, an interview with Don Syme and a discussion on the Visitor Pattern’s place in F#.  Also, any comments on the new title for my weekly posting would be appreciated.

 

Forum – Memoization and Lazy Evaluation in F# on HubFS

In this thread brianmcm (Brian McNamara) and divisortheory (???) explore using memorization and LazyLists to optimize a Trial Division driven prime generator.  It’s interesting to look at how their prime generator evolved over time as they incorporated these ideas and optimized.

 

Article – Kathryn Edwards interviews Don Syme on F# Development

In this technically light but still extremely interesting interview, Kathryn mainly directs the conversation in the direction of the development and adoption of the F# programming language.  The most interesting thing I gleaned from the interview?

One of the key designers of Haskell, Simon Peyton-Jones, is just down the corridor from me at Microsoft Research Cambridge and has been a great help with F#.

Perhaps my F#/Haskell genealogy graph needs an additional arrow.

 

Blog – Stephen Easey’s (?) Visitor Patten in C# and F#

In this post Stephen explores the Visitor Patten in both C# and F#.  I always love to see examples of how much more beautiful and concise F# is than C#.  The 218 line C# implementation shown beside the same implementation in 64 lines of F# makes for a great comparison in this regard. 

I agree with Stephen’s conclusion in that, given the purpose of the visitor pattern is to separate algorithm from object via a double dispatch layer, in many situations the visitor pattern is unnecessary in F# because of its advanced pattern matching capabilities.

However, I feel that he may not have considered the perspective of an API provider.  In this context, it may be desirable for the consumer of an API to be able to extend the dispatch process to handle new cases.  The issue with a single monolithic matching function is that all of the logic is contained within that single function and so the system is no longer nearly as open to extension.  This violation of the Open Closed Principle (which applies to building APIs in any type of language) will make for difficult to reuse software. 

Perhaps a F# pattern matching equivalent could be made with lambda functions for each branch.  Lambdas could be curried into the matching function and so each branch could potentially be replaced with new logic by the consumer.  However, this is feels to me like reimplementing OO with FP constructs.

Functional Discoveries in the Microsoft Sociocosm 02/20/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich February 20, 2009 17:41

This week we have practical examples of Lazy Evaluation with Memoization, an interview with Don Syme and a discussion on the Visitor Pattern’s place in F#.  Also, any comments on the new title for my weekly posting would be appreciated.

 

Forum – Memoization and Lazy Evaluation in F# on HubFS

In this thread brianmcm (Brian McNamara) and divisortheory (???) explore using memorization and LazyLists to optimize a Trial Division driven prime generator.  It’s interesting to look at how their prime generator evolved over time as they incorporated these ideas and optimized.

 

Article – Kathryn Edwards interviews Don Syme on F# Development

In this technically light but still extremely interesting interview, Kathryn mainly directs the conversation in the direction of the development and adoption of the F# programming language.  The most interesting thing I gleaned from the interview?

One of the key designers of Haskell, Simon Peyton-Jones, is just down the corridor from me at Microsoft Research Cambridge and has been a great help with F#.

Perhaps my F#/Haskell genealogy graph needs an additional arrow.

 

Blog – Stephen Easey’s (?) Visitor Patten in C# and F#

In this post Stephen explores the Visitor Patten in both C# and F#.  I always love to see examples of how much more beautiful and concise F# is than C#.  The 218 line C# implementation shown beside the same implementation in 64 lines of F# makes for a great comparison in this regard. 

I agree with Stephen’s conclusion in that, given the purpose of the visitor pattern is to separate algorithm from object via a double dispatch layer, in many situations the visitor pattern is unnecessary in F# because of its advanced pattern matching capabilities.

However, I feel that he may not have considered the perspective of an API provider.  In this context, it may be desirable for the consumer of an API to be able to extend the dispatch process to handle new cases.  The issue with a single monolithic matching function is that all of the logic is contained within that single function and so the system is no longer nearly as open to extension.  This violation of the Open Closed Principle (which applies to building APIs in any type of language) will make for difficult to reuse software. 

Perhaps a F# pattern matching equivalent could be made with lambda functions for each branch.  Lambdas could be curried into the matching function and so each branch could potentially be replaced with new logic by the consumer.  However, this is feels to me like reimplementing OO with FP constructs.

Discoveries This Week 04/03/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich April 05, 2009 01:42

With the start of our F# User’s Group this next Monday and New England Code Camp 11 last weekend, things have been extremely busy this past week.  Meanwhile, the F# sociocosm is growing at a rapid pace.  This week we have a talk by Don Syme, a look at F# quotations, and finally, some discussion on Seq.unfold.

 

Chris Bowen’s Post, Announcing F# User Group in Cambridge - April 6

A shameless plug here for our new user group.  A big thanks to Chris for helping us find the resources we needed to start out.  Without him this might never have come together.

 

Don Syme’s Talk, F# and functional programming in .NET

As Don Syme is the father of F#, when he speaks the community listens.  In this talk Don focuses on the pleasure and speed inherent in using FP and F#.  He does this by describing the functional methodology and constructs which provide a simpler and more elegant model for building programs.

 

Alex P’s Post, F# quotations at their simplest

A simple example on the surface for sure.  However, if you haven’t seen the power of F#’s language oriented programming features this is sure to be of interest.

For a deeper look at the power of quotations check out Tomáš Petříček’s F# quotations visualizer.  If his past projects are any indication Tom’s upcoming book is a must have for any F# enthusiast.  I preordered a copy just today.

 

Martin Peck’s Post, Solving Problems in C# and F# - Part 2 
(and update)

One of the most fantastic things F# has to offer is the rich functional programming heritage of sequence operations.  To demonstrate how elegant they can make your code, I would like to offer the following alternative F# solution:

let fibs = 
  Seq.unfold (fun (a, b) -> Some( a, (b, a+b) )) (0I, 1I)
Seq.find (fun n -> n >= 10I ** 999I ) fibs

I’m going to take this opportunity to point out the obvious: we have here two lines of F# which does almost exactly the same thing as thirty six of C#.   Now that’s what I call power and elegance.  The unfold function pretty much does exactly what yield was doing before, but implicitly in terms of the unfold function.  The idea of unfold can be confounding at first and so here is a breakdown of how it works:

let fibs =
  Seq.unfold 
    (fun (a, b) -> //generator function, 
//
(a, b) is the previous state Some //Option monad, needed for unfold (a, (b, a + b))) //returned tuple: (value, state)
//or (
first, (second, third)) (0I, 1I) //Initial function state (first, second)

Note that in this version the state of the next two values in the sequence are always pre-calculated.  However, it is easy to avoid this if you instead consider the state in terms of the previous two values: 

let fibs = 
  Seq.unfold (fun (l, l2) -> 
    let n = l + l2 in Some( n, ( n, l ) ))
    (0I, 1I) //(previous, second previous)

If you want to learn more about unfold I recommend checking out:

 

Dustin Campell’s Post, Apples and Oranges

This is the best description of how unfold works I’ve seen to date. 

 
 

F# Discoveries This Week 08/08/2010


Published to Rick Minerich's Development Wonderland by Richard Minerich August 08, 2010 18:57

So many links, all well worth your time.  I know one thing I won’t be missing is Don Syme’s online talk at C4FSharp on 8/17.  It’s great to be part of a language community in which the founder interacts in such a direct way.

 

News

Draft F# Component Design Guidelines now Available (pdf)

Don Syme will be speaking online for the Community for F# on 8/17

I’ll be speaking at the NYC ALT.NET User Group on 8/25

Kevin Hazzard’s Slides from DevConnections are up

Howard Mansell will present Eden: (An F#/WPF framework for building GUI tools) at CUFP

F# is now at 93% on langref, only 1% behind scala. (Great Going!)

PexForFun.com now has puzzles for F#

FSharp Cross Platform Packages and Samples 1.1 Released

 

 

Audio/Video

Jon Harrop at the London F-Sharp User Group: QR Decomposition

This lecture takes the audience from a tiny numerically-robust implementation of a common linear algebra algorithm through several stages of optimization, culminating in a high-performance solution that easily outperforms Intel’s Math Kernel Library. The algorithm studied is QR decomposition, which is commonly used for linear least squares best fit.

 

 

F# Articles

Adam Granicz’s Expert F# 2.0 – what’s new?

There comes a time when you just have to stop working for a minute and take a few moments to enjoy the fruits of your hard labor. For me, one of these moments lately came when I received the author copies of our book, Expert F# 2.0

 

Daniel Mohl’s F# Templates Now On Visual Studio Gallery

As Don Syme mentioned in a recent blog post, I've been working to get the five F# templates that have been announced on this blog up on Visual Studio Gallery.  I'm happy to say that all are now available.

 

Vagif Abilov’s Mock framework challenges in F#

So far I only tried very basic mocking described in the first post of Richard’s series: faking return value. As I expected, even such a simple operation became a challenge when executed from F# code. I managed to make tests work only for two and half frameworks.

 

Mauricio Scheffer’s Figment: a web DSL for F#

As I said, this is very much work in progress, and there's still a lot to do. I intend to make it fully open source when I finish writing my thesis.

 

Neil Carrier’s Segment Tree in F#

Suffice to say that a segment tree stores a group of intervals on an ordered set, in such a way that all the intervals containing a given value can be efficiently located. Such a query is sometimes called a “stabbing query,” because it’s like sticking a spear through the data and seeing which entries get stabbed.

 

Neil Carrier’s F# Sequence Lazy Evaluation Gotchas

Today’s post will be old news to experienced F# programmers. Actually, it’s old news to me, relative newcomer that I am. However, it’s one of those things I tend to forget until it jumps up to bite me, as it did today.

 

Edgar Sanchez’s F#, the ACM, and the SEC

And it is this last recommendation on DSLs that carries interesting news for F# because at the end of page 6 it states “Experience seems to show that higher-order programming languages such as F# provide a particularly good basis for domain-specific languages.

 

Jon Harrop’s Pure F# now only 2× slower than OCaml

This is a surprising and encouraging result not only because it makes F# competitive for an even wider variety of tasks but because it also implies that Microsoft are taking F# so seriously that they are optimizing the .NET garbage collector for it!

 

Steve Hawley’s Protect Yourself

One solution is to label things that need to be protected, disassemble the output, run a regular expression to search/replace the accessibility and reassemble.

 

F# and .NET needed at Credit Suisse? Is there a future for this and Microsoft in the quant world?

As I said, when you compare to these other languages in the world of quant, F# appears to be taking an early lead.

 

Stefano Ricciardi’s Project Euler Problem 4 in F#

The actual algorithm uses brute force to test for palindromicity (neologism?) all the numbers that can be composed multiplying together 3 digits numbers (those from 100 to 999), picking the highest one.

 

 

Miscellaneous

Lambda the Ultimate’s OSCON 2010 Emerging Languages Camp Roundup

F# Discoveries this Week 07/09/2010


Published to Rick Minerich's Development Wonderland by Richard Minerich July 09, 2010 17:42

This week we once again reap another huge crop of fantastic F# content.  In fact, it’s been getting so overwhelming that I’ll be moving to an every week format from here on out.  Please come in, read, and enjoy! 

 

News

A New F# Case Study on Microsoft.com

With its new tools, the bank can speed development by 50 percent or more, improve quality, and reduce costs.

 

Next F# London Meetup Announced: July 28th

The next meetup of the F#unctional London Meetup Group will be held on July 28, with Zach Bray talking on Agile Acceptance Testing with F#

 

Tim Anderson (of The Register) Interviews Don Syme

I met Syme at the QCon conference in London, in March 2010, and interviewed him shortly afterwards. Some quotes from that interviewed have already been published in an article for The Register, but I am now posting nearly all of it here.

 

DotNetKicks Now has a F# Section

Thanks to everyone on twitter who voted!

 

Quantifa 0.0.2 Released

Quantifa is an F# open-source library for quantitative finance and risk management.

 

F#-mode for Emacs updated to 0.3

The F# mode for Emacs is two years old, and has been downloaded more than 1,000 times.

 

Tables: Organize Your Files. Written in F#

Tabbles is a new way of organizing files: it combines virtual folders and tags, and auto-organizes and tags your files in very intelligent ways.

 

 

Audio / Video

Svea Ekonomi on F# for automated billing system for the Telecom industry

In earlier versions of the billing system, much of the business logic resided in SQL Server and various Perl and Java programs. That made the solution hard to maintain and tailor to the needs of the customers. By using F# instead of an object oriented language the developers at Svea Ekonomi can be a lot more productive.

 

 

Articles

 

Ian Voyce’s Minilight renderer in F#

I’m a sucker for eye-candy, and the other day I came across the beautifully lit renders produced by Minilight. It’s a nice, minimal implementation of a global illumination renderer that’s been ported to a wide variety of different languages from C to ActionScript. So of course, I couldn’t resist trying to implement it in F#.

 

Jon Harrop’s F# vs Mathematica: fast pricer for American options

Another example from Sal Mangano's Mathematica Cookbook, this time taken from Andreas Lauschke's example, is a "fast" pricer for American options. The relevant section of the book stresses the importance of performance in this context and the Mathematica code presented was heavily optimized by experts.

 

Jon Harrop’s F# vs Mathematica: parametric plots

Another example from Sal Mangano's Mathematica Cookbook (p.520) is an elegant little Mathematica program that uses a crude numerical integrator to plot the trajectory of a differential equation representing the populations of predators (foxes) and prey (rabbits):

 

Jon Harrop’s F# vs Mathematica: red-black trees

The simpler F# solution is also 20× faster at inserting 100k elements and 100× faster at computing the range of depths in the resulting tree.

 

Jon Harrop’s Lorenz Attractor

The Lorenz attractor is a fractal derived from the trajectory of a 3-dimensional dynamical system that exhibits chaotic flow. This blog post describes a 35-line program that computes trajectories of this attractor and visualizes them as a beautiful whisp using Windows Presentation Foundation.

 

Neil Carrier’s Composable Order Relations

Even before I started experimenting, I realized that checking a list for sorting was just a specific example of checking whether the pairs in a list satisfied a certain binary order relation. So I decided to work directly on a more general solution.

 

Neil Carrier’s Continuation-Passing Mnemonics

Learning to construct continuations can be tough. It’s easy to state how they work: they facilitate tail recursion by recursively passing the remainder of a computation. But it can be a lot harder to actually get one working from scratch.

 

Neil Carrier’s Dijkstra’s Shunting-Yard Algorithm

Without further ado, here is my first F# implementation of Dijkstra’s shunting-yard algorithm, including a basic test (based on the example at Wikipedia). This is probably not a minimal or most-efficient implementation, but it is a starting place.

 

Neil Carrier’s Arity and Unit Arguments in F# 2.0

While working on an internal domain-specific language, I encountered a case where passing a unit into a function made the syntax somewhat more readable. The completely artificial example below illustrates the concept as the function xfer1. I also tried a two-unit version, which is illustrated as xfer2.

 

Daniel Mohl’s Presentation: 5 Best Practices for F# Development slides and examples

Thanks to all who come out to the New England F# User Group meeting tonight!

 

Tomas Petricek’s Dynamic in F#: Reading data from SQL database

If you ever tried to call a SQL stored procedure directly using the SqlCommand, then you can surely appreciate the elegance of this code snippet. Let's now take a look at a larger example and some of the neat tricks that make this possible...

 

Erik Schulz’s Cartesian Tree Sort – Revisited, Cartesian Tree Sort – Skew Heap and Beating Quick Sort - Cartesian Tree Merge

After looking at skew heap, merge sort and Cartesian tree, I figured there has to be a way to combine all three.

 

Julien Ortin’s SEO Analysis in F#, and SEO Analysis in F#, a friendly application

Last time, we created a library of Search Engine Optimization (SEO) helpers. This time we’ll see how to use them to actually fetch information about your webiste rankings (and your competitors’).

 

Julien Ortin’s European Central Bank – extracting reference rates with F#

Every day, the European Central Bank publishes “official” reference FX (foreign exchange) rates where currencies are quoted against the Euro (expressed as EUR/XXX), or 1 EUR = xxx XXX. The exchange rates of the last thirty sessions are available in xml format which we shall try to parse.  In order to do so, we use F# and active patterns, based on Don Syme’s draft paper.

 

Anton Tayanovskyy’s Optimizing JavaScript with F#

The need for optimizing JavaScript is very peculiar. This is not about delivering top wall-clock performance, but rather delivering the most compact (in Release mode) and most readable (in Debug mode) source. In the case of WebSharper™, it is also about relieving the compiler and the macro writer from the burden of emitting optimal code.

 

Chris Ballard’s My First F# Post

That said, this post will take you through my solution for Euler 54, which (somewhat unusually) isn't a particularly mathematical problem, but turns out to be a great way to demonstrate some of the features of the F# language. The basic principle of this problem is to compare two hands of cards in the game of poker, and to determine which is the winning hand.

 

Chris Ballard’s Prime Numbers - Building the EulerMaths library in F#

Those of you who are doing Project Euler know what I am talking about by the EulerMaths library. There are certain fundamentals which crop up again and again in the questions and it is important to work these into a reusable and performant library.

 

Daniel Mohl’s WPF MVVM Multi-Project Template: A Polyglot Approach

As an advocate for using the right tool for the job, I have created a new WPF MVVM multi-project template composed of an C# View project, an F# ViewModel project, and an F# Model project. 

 

Rodolfo Ortega’s Eliza like chat bot in F# language for fun

This is a very simple Eliza like chat bot. I call it Meliza Sharp. I wrote it for having fun learning the F# language shipped with Visual Studio 2010.

 

Mauricio Scheffer’s Abusing PrintfFormat in F#

Pretty cool, huh? This trick can be used for other things, since PrintfFormatProc is fully reusable. For example, I'm currently using PrintfFormat manipulation to define type-safe routing in a web application

 

Mark Pearl’s Depressingly simple text file access

Today I was doing some work work and kept having to parse a log file. After a few hours of doing the same routine stuff I thought I might try and automate it using F#.

 

Mathias’s On the road from C# to F#: reading stock quotes and more stocks

Mads Kristensen has a nice post where he shows how to read  stock quotes from Yahoo finance using C#, which was very helpful to get started. I figured it would be interesting to try out a conversion to F# and see what the result looked like.