Adding Meaning to Primitive Types in fsharp

One of the recommended guidelines in Domain Driven Design is modelling the domain ideas using the domain type (CustomerName, CustomerId) instead of using their corresponding primitive type (string, int). In fsharp, with the help of Single-Case Discriminated Union, we can follow this guideline with minimal effort. While following this practice in one of my recent project in fsharp, I came across a compelling use case, and I used a lesser-known approach to solve the problem.

Introducing FsConfig

I am delighted to introduce a new F# library, FsConfig. FsConfig is a F# library for reading configuration data from environment variables and AppSettings with type safety Why FsConfig? To understand FsConfig, let’s have a look at an use case from the FsTweet application. The FsTweet application follows The Twelve-Factor App guideline for managing the configuration data. During the application bootstrap, it retrieves its ten configuration parameters from their respective environment variables.

Generic Programming Made Easy

Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters1. Generic programming was part of .NET since .NET Version 2.0 and has a fascinating history as well! For most of the use cases which involves generics, implementing them in F# is a cake-walk. However, when the generic programming requires reflection, it becomes a bumpy ride.