Tag / monoids

Maybe you did not like the way the structure of the monoids was passed around using a simple record and indeed there is a way to define the Z and ++ as generic operators by exploiting Statically Resolved Type Parameters in F#.

As far as I know this was first mentioned here and there is a great project on github using this FsControl.

Rewriting some of the instances this way can look something like this:

my take on it

First let me make clear that I love how those guys managed to put this all together! – this is a major hack of F# and it’s type-system. It’s one of the most clever thing I saw using F# and I am really impressed by all Gustavo did there.

But for me this is just to much boiler-plate only to get simulated type-class support that really should be there in the language itself (or maybe better: a ML-like module system). In the end at this point this is just used to get function-overloads based on type (a great feature). At the moment I prefer to use modules (like List.map, Option.map) – yes the compiler could know this but for me it’s no big deal.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

disable

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.