Suppose I have a type like this:
type Season =
| Spring
| Summer
| Autumn
| Winter
I want to have a function next that returns the next season:
let next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
There are two places I can put this function.
In a named module:
module Season =
let next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
Or as a static member on the type:
type Season =
| Spring
| Summer
| Autumn
| Winter
with
static member next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
What are the reasons to favour each approach?