United Kingdom: +44 (0)208 088 8978

Libraries we love to use with SAFE Stack

Matt discusses some of Compositional IT's favourite libraries for making SAFE Stack even better!

We're hiring Software Developers

Click here to find out more

Libraries we love with SAFE Stack

The SAFE Template provides a great starting point for getting going with SAFE Stack. The F# ecosystem provides plenty of additional libraries that you can use in combination with or instead of those provided by the template to enhance your experience. This blog post will be a whistle-stop tour through some of our favourites.

Functional programming

FsToolkit.ErrorHandling

FsToolkit.ErrorHandling provides utility functions to make working with Result and Option types easier. It also has a few excellent computation expressions such as asyncResult, which simplifies working with Results in an asynchronous context. Ryan has a great post showing how easy it makes validation.

UI

Feliz.DaisyUI

Recently, we've enjoyed using Feliz.DaisyUI because of the flexibility DaisyUI offers compared to Bulma, which the SAFE Template offers via Feliz.Bulma. I wrote a brief introduction in a previous blog post.

Feliz.AgGrid

We find Feliz.AgGrid - a library we've put together ourselves - pretty useful too! It allows us to use the fantastic functionality provided by AG Grid in our Elmish front ends.

Data Access

Facil

Facil is simply awesome. Given a connection to a SQL Server database, it can generate F# records representing the database object. Given the location of files containing SQL queries, it can generate F# functions for executing them. It can even generate F# functions for basic CRUD operations against tables without you having to write any SQL. Kash has a post on Facil as part of his series on working with SQL from F#.

We love to use it in combination with a .NET Core database project in our solution and Docker database containers for local development.

Azure Storage

We host our apps on Azure. The following SDKs are useful for interacting with Azure storage:

Resilience

Polly

Polly is a great library for specifying how your app should handle faults and providing ways to make it more resilient. I have a blog post showing configuration of some basic Polly policies in F#

Testing

YoloDev.Expecto.TestSdk

The SAFE Template comes bundled with the Expecto testing library. YoloDev.Expecto.TestSdk allows you to run your Expecto tests using dotnet test.

FsCheck

FsCheck is a property-based testing library for F#. That is, it is used to generate random test data and check that a specified property holds for all given inputs to a function. It's an approach that can enable radically different tests to what you might otherwise get. Our blog has a few examples of what you can do with it.

Benchmark.NET

Benchmark.NET is for measuring code performance. Isaac has an interesting post on using Benchmark.NET where he uses it to test mapping across different collection types.

NBomber

NBomber allows you to test how your application holds up under load. Isaac has another excellent post, demonstrating how to get started with NBomber

Profiling

Microsoft.ApplicationInsights.Profiler.AspNetCore

Microsoft.ApplicationInsights.Profiler.AspNetCore can be used to send profile information to Application Insights.

Logging

Serilog

Serilog is a great .NET logging library. We integrate it with our server logging using Serilog.AspNetCore and send those logs to Application Insights using Serilog.Sinks.ApplicationInsights.

Destructurama.FSharp

We use Destructurama.FSharp to improve Serilog's destructuring of F# data types. Try out the project's samples to see the difference.

Summary

As promised, that overview was quick(!) — hopefully the links give you enough to get going if you want more information. Have fun experimenting and using these libraries to enhance your SAFE Stack experience!