What is it?

You can write posts in Firm in literate programming style. What that means is that instead of writing documents in markdown text and specifically format the parts that contain code, you turn it around and make code your main content and embed text as comments. The major upside of this is that the source of your post or page is an fsharp script file (.fsx) that can be run in e.g. Visual Studio.

Made possible by

The fsharp script file is fed to FSharp.Formatting, which does all the heavy lifting.


Here are some code snippets copied from http://fssnip.net with the solution the first Project Euler problem (find the sum of all multiples of 3 or 5 below 1000).

First the range.

let range = [0..999]

Then the predicate that checks for multiples of 3 or 5.

let condition x = x % 3 = 0 || x % 5 = 0

And finally the function that runs the above declared predicate on the range and sums it up using built in library functions.

|> List.filter condition 
|> List.fold (+) 0

More examples

You can find an example that covers pretty much all features on the FSharp.Formatting documentation site.

You can check the source of this blog post to see the actual script.

val range : int list

Full name: Index.range
val condition : x:int -> bool

Full name: Index.condition
val x : int
Multiple items
module List

from Microsoft.FSharp.Collections

type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val filter : predicate:('T -> bool) -> list:'T list -> 'T list

Full name: Microsoft.FSharp.Collections.List.filter
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State

Full name: Microsoft.FSharp.Collections.List.fold