Proposal: Add log1p and expm1 to GHC.Float.Floating

Edward Kmett ekmett at gmail.com
Sat Apr 19 12:49:45 UTC 2014


With the defaults the code is never worse than it is forced to be right now
and users do not need to create CPP blocked code to work around this
addition.

Without the defaults this becomes a much bigger request, as I'd be asking
_every_ author of Floating to add CPP to their packages for a feature they
never heard of and probably will never use, and in that situation we'd have
to export it from Prelude.

Given the trade-off between those factors I tend to favor adding defaults
to not.

-Edward


On Sat, Apr 19, 2014 at 5:42 AM, Scott Turner <2haskell at pkturner.org> wrote:

>  On 2014-04-17 15:08, Edward Kmett wrote:
>
>  On Thu, Apr 17, 2014 at 2:48 PM, Henning Thielemann <
> schlepptop at henning-thielemann.de> wrote:
>
>> I think one should add default implementations. They don't have an
>> numerical advantage but they save programmers from code breakage.
>
>
>  I included the default definitions in code snippet in the proposal, so
> user code that remains unaware of them would be unaffected, while packages
> like compensated, or a wrapper around libqd could implement them as needed.
>
>  expm1 :: Floating a => a -> a
> expm1 x = exp x - 1
>
>  log1p :: Floating a => a -> a
> log1p x = log (1 + x)
>
> On the contrary, code that explicitly uses these functions is likely to
> need the precision. Defaults would cause subtle breakage.
>
> -- Scott
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140419/30c75805/attachment.html>


More information about the Libraries mailing list