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

Edward Kmett ekmett at gmail.com
Mon Apr 21 01:42:43 UTC 2014


The problem there is that now you can't just replace log (1 + x) with log1p in your code, you have to reason through case by case about an open universe of instances you don't own, to know whether it is a safe transformation.

I use type classes to quotient that sort of case by case reasoning out of my thinking.

> On Apr 20, 2014, at 9:25 PM, wren romano <winterkoninkje at gmail.com> wrote:
> 
>> On Sun, Apr 20, 2014 at 8:49 PM, John Lato <jwlato at gmail.com> wrote:
>>> On Sun, Apr 20, 2014 at 5:20 PM, Edward Kmett <ekmett at gmail.com> wrote:
>>> I know for me personally it would force me to double the amount of numeric
>>> code I write, just to maximize my audience. I really don't want to go there.
>>> I just want to be able to call the function I mean, and to be able to talk
>>> to the right people to make it do the right thing.
>> 
>> exp1m = error "Go bug some library author to implement exp1m"
>> 
>> would accomplish that even more efficiently, since it will directly point
>> users to the right people.
> 
> FWIW, because log1p/expm1 etc are not part of the current API, this
> too is a strictly monotonic improvement over the current state of
> things: users who don't know/care about the new functions don't need
> to change anything, and users who do care are beholden to see that
> they are implemented correctly. No need for CPP. And no misleading
> implementations of the fused functions.
> 
> I'm +1 for these defaults.
> 
> -- 
> Live well,
> ~wren
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries


More information about the Libraries mailing list