I am doing some Monte Carlo simulations on dice rolls using F# and I am using integers to represent a single roll of a dice and a list of integers to represent a list of dice rolls. I would like to be able to model the dice roll instead of integers as a type. I am only using 6 sided dice and I would like a type that has some of the characteristics of a Alias / Synonym type and some of the properties of either a Discriminated Union or a Enum.
These are what I would like to see on my type
I have tried the combination of types listed above and all seem to have some draw backs (which might be my usage and understanding rather than the Types themselves).
This is just a trivial example of something I am doing for fun (not profit) but would like to see an answer as I could imagine using this in more serious data modelling.
As one of the options you could create your own numeric type as described in this post by Tomas Petricek: http://tomasp.net/blog/fsharp-custom-numeric.aspx/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With