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

wren romano winterkoninkje at gmail.com
Thu Apr 24 04:09:06 UTC 2014


On Wed, Apr 23, 2014 at 11:55 PM, Edward Kmett <ekmett at gmail.com> wrote:
> As a straw-man / olive-branch / half-baked idea:
>
> Could we get you what you want by simply making an extra class to indicate
> the claim that the guarantee holds, and get what I want by placing these
> methods in the existing Floating with the defaults?

Another alternative along the same lines and just as ugly:

* Introduce a new class for these high-precision methods.
* Define a `newtype Dodgy a = Dodgy a` which gives the obvious but not
necessarily precise implementations.

Pros:
* we don't have a class without methods
* the providence of improved precision is made clear in the type (pro
jlato/myself)
* can use the interface even without improved precision (pro ekmett)

Cons:
* newtype noise whenever fallback is necessary. Individual functions
are not affected by this noise, however the noise may leak into the
rest of the program (contra ekmett, at least in spirit)
* the desire for improved precision leaks into the types (contra ekmett)
* can use the interface even without improved precision (this may seem
conta the spirit of my/jlato's goals, but since the fallback is
documented in the types it is therefore okay by me)

-- 
Live well,
~wren


More information about the Libraries mailing list