Closed goldfirere closed 2 years ago
Do you get any power more over converting to Either Integer Double
? and then using fromInteger
or realToFrac
.
In any case, conditional APIs are out of question.
Do you get any power more over converting to
Either Integer Double
? and then usingfromInteger
orrealToFrac
.
Potentially, I imagine, if, say, the floating-point representation had more precision than Double
, or the integral representation were optimized to store numbers in the range expected in a particular application. My particular needs don't imagine such exotic scenarios, but I'm building a library whose users may indeed have them.
I feel confident that my suggested function is useful in scenarios that the current API does not serve. Whether these scenarios arrive often enough -- or whether the benefit is large enough -- to be worth the cost of maintaining and documenting the function (and potentially confusing users about which variant to choose), I don't know.
In any case, conditional APIs are out of question.
Fair enough. I would likely agree in your shoes. Thanks for entertaining the thought!
I'm writing a rather dynamically typed application where I need to convert a
Scientific
, but I don't know the types to convert to until after I know whether theScientific
is floating or not. But the current interface tofloatingOrInteger
requires preselection of the types.Happily with
-XImpredicativeTypes
, we can make a more general interface, though it has downsides, as documented in this patch.I'd understand if this is too, say, avant garde for this library, but I thought I'd give a shot at suggesting this.