Am 17.04.2014 19:15, schrieb Edward Kmett:No question, these functions are useful. But I think there should be two proposals:
log1p and expm1 are C standard library functions that are important for
work with exponentials and logarithms.
I propose adding them to the Floating class where it is defined in
GHC.Float.
1) Add log1pFloat, log1pDouble, expm1Float, expm1Double to GHC.Float
2) Extend Floating class with log1p and expm1 methods.
I think the first item is unproblematic since it is a simple addition. Since FPUs sometimes directly implement log1p and expm1 functions, I wonder whether GHC also should support the according machine instructions. E.g. x86 has F2XM1 and FYL2XP1 and good old MC68882 had FETOXM1 and FLOGNP1.
The second item means to alter the Floating class which affects all custom Floating instances. I think one should add default implementations. They don't have an numerical advantage but they save programmers from code breakage.
Not exporting them from Prelude still means to export them from GHC.Float, right? I mean, users must be able to implement these methods for custom types like extended precision floating point numbers as provided by libqd. But there should also be a non-GHC module that exports the full Floating class.We do not have to export these from Prelude. My knee-jerk reaction is
that we probably shouldn't.