A frequent question I get is how to structure a codebase in F#. There is not much about this topic out there on the Internet. So here is how we structure our code:
Today’s random F# code: Regex Active Pattern in API Validation
Today’s random F# code: Nice test error messages with Unquote and Diffract
When comparing complex data types in unit test assertions, for example, records with nested lists containing discriminated unions, the error messages quickly get hard to understand. How to spot a single difference?
That’s why I mixed Unquote and D-Edge.Diffract together.
An example unit test from our codebase:
Today’s random F# code: Domain modelling with discriminated unions
Today’s random F# code: Result instead of exceptions
Today’s random F# code from our app is about using Results instead of using exceptions.
Do you often need to get some data from the database, but it’s not sure that the requested data exists? And you don’t like using exceptions for this because exceptions are for really unusual things? Then use a Result:
Querying data with the help of Result
Today’s random F# code: validation
Today’s random F# code: Type inference