I’m working on parsing with haskell, I want to parse a timestamp value expressed in such a way
946685561.618847
I have no problem to recognize (parse) it, but my problem is about the type of the result. I think of two situations:
- Is there a fractional type in Haskell so that the result can be associated with the fractional value?
- If this is not the case then how to store this value, since
Intrange from -229 to 229 – 1?
There are actually multiple fractional types–there is even a whole
Fractionalclass.The most commonly used is a
Double, which is a double-precision floating point number. You can also useFloatwhich is single precision.Another alternative is to use the
Rationaltype, which lets you store a number as a ratio of twoIntegers. (Coincidentally,Integeris an unbounded integral type.Intis the name for the bounded version.)These types (
Double,FloatandRational) are good for storing rational values. If you just want to store a large integral value, useIntegerwhich is unbounded. (That is, it can store arbitrarily sized integers.)