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

Scott Turner 2haskell at pkturner.org
Sat Apr 19 09:42:30 UTC 2014


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
> <mailto: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/278fa5e5/attachment.html>


More information about the Libraries mailing list