I have some work at the moment that might need to manipulate floating point numbers. However, I realised that it’s probably sufficient to just work with rationals, which are much simpler. I can represent a rational as Ratio = { numerator : Natural, denominator : Natural }
. However, this is pretty horrible for users to construct. For example, I want to write 0.001
, but I have to write { numerator = 1, denominator = 1000 }
- this example took me many seconds to write to work out exactly how many zeros I needed!
We’ve got the normal escape hatch of postulating Text/parse-Ratio : Text -> Ratio
, but can anyone think of anything else?