Strange Confluence: An Immutable Queue in F#

Jomo Fisher–Reading one of my favorite blogs this morning–Eric Lippert’s Fabulous Adventures in Coding–I came across his article on implementing an immutable queue in C#. The funny thing is that just yesterday I wrote exactly the same structure in F#. Here it is for your reading pleasure:     type Fifo<‘a> =         new()={xs=[];rxs=[]}         new(xs,rxs)={xs=xs;rxs=rxs}…


Tight Code--A Puzzle in F#

Jomo Fisher–Luke Hoban wrote something in a blog entry that resonated with me: One of the most striking features of F# code is that it is very terse – ideas can typically be expressed with a small amount of code.  Don Syme once mentioned (I’m paraphrasing) that an aspirational goal for F# in the beginning…


F# Team is Hiring

Do you want to help us ship F#? Check out these job postings: Developer: Tester:


The Least a C# Programmer Needs to Know about F# Part II--Modules

Jomo Fisher–Many languages, especially those in the OO vein, require an outermost class to put code in. Usually, good practice requires an enclosing namespace as well.  F# allows functions and even function calls in the outermost scope. Here is the minimal F# program:   printf “Hello!”   Really, that’s the whole thing. My first concern…


WideFinder--Naive F# Implementation

Jomo Fisher–Here’s an interesting problem that some people are having fun with. Don Box posted a naive implementation in C# so I thought I’d post the equivalent in F#:  #light open System.Text.RegularExpressions open System.IO open System.Text   let regex = new Regex(@”GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+)”, RegexOptions.Compiled)   let seqRead fileName =     seq { use reader…


The Least a C# Programmer Needs to Know about F# Part I--Implicit Types

Jomo Fisher–A few weeks ago, a fellow C# programmer asked me what the biggest differences between programming in C# and programming in F# are. Since then, I’ve been building a list of differences. My plan was to write a single article that discussed everything. This morning the list got too long to reasonably put in…


Soma on F#

Soma announced some exciting news this morning. Developer Division–the people at Microsoft who make Visual Studio–is partnering with Microsoft Research on F#. We’re going to fully integrate F# into Visual Studio: “This is one of the best things that has happened at Microsoft ever since we created Microsoft Research over 15 years ago.  Here is…


Adventures in F#--Sweet Test-First Kung Fu

Jomo Fisher–Up until now, I’ve been avoiding using F# with the VS IDE. I’ve been using notepad.exe and fsc.exe because I wanted to build my own expectation for what the experience should be before I experienced what it actually was. I can tell you that I didn’t expect the sweet experience of using the F#…


Adventures in F#--Lazy Like a Fox

Jomo Fisher–This is the next part of the open-notebook series documenting my exploration of F#. Today, I’m looking at the lazy keyword. When an F# function is invoked its value is immediately evaluated. F# does not do lazy evaluation by default. However, laziness can be useful and F# provides an easy way to make a…


Adventures in F#--Corecursion

Jomo Fisher–In a prior post I touched on recursion in F#. One of the comments was about mutually recursive functions. The example given was, let f1 a do print a f2 a let f2 a do print a f1 a f1 1 It turns out that this F# doesn’t compile because F# scoping rules are…