F#

F# – Extending Discriminated Unions using marker interfaces

One of the problems with using F#’s Discriminated Unions is that they are not extensible, in that all your union cases must be specified inside one Discriminated Union (abbreviated to DU from this point) type and you can’t inherit from an existing DU type to add additional union cases. In most cases, having to specify …

F# – Extending Discriminated Unions using marker interfaces Read More »

F# – Serializing F# Record and Discriminated Union types

I love using F#’s Record and Discriminated Union types, they work nicely with pattern matching inside your F# code and can often alleviate some of the ceremony involved around creating and using a complex object hierarchy. However, on the odd occasion when you need to serialize them into JSON/XML/Binary format, it might not be immediately …

F# – Serializing F# Record and Discriminated Union types Read More »

F# equivalent of C#’s Object Initialization syntax

In C#, you can use the object/collection initialization syntax like this: The F# equivalent of object initialization is done like this: As for collection initialization, you have a far more diverse range of tools available to you, for example: You can also create slices of an existing array: You can even add your own multi-dimensional …

F# equivalent of C#’s Object Initialization syntax Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close