Snippets tagged Discriminated Unions

  • IRC Jokes

    Simple snippet that demonstrates recursively defined discriminated unions, the Y combinator (for encoding recursive functions) and recursive processing of tree-like structures

    5 people like this

    Posted: 4 years ago by Daniel Jackson

  • Tesco in 70 lines of code

    Domain model for the Tesco checkout implemented in F# using discriminated unions (in 20 lines of code) and console-based user interface for scanning products and calculating the total price.

    4 people like this

    Posted: 3 years ago by Tomas Petricek

  • Defining union cases that have the cons ( :: ) pattern

    Here I give an example of a data structure known as a skew binary list and also an example of how to use the cons pattern, normally reserved for FSharp lists, in your own union cases. It is not possible to do the same with the nil union case, []. Nor is it possible to use any other symbols (as far as I know). This kind of sucks.

    2 people like this

    Posted: 2 years ago by Greg Ros