<div dir="ltr">The option you seem to be left unsaid is implementing them correctly.<div><br></div><div>A lot of the reason for Data.Fixed is you actually require the accuracy they claim. But these functions aren't magic, they can be calculated to a given accuracy from their power series approximations, among several other good methods which are easy to implement and several more methods which are faster. It would seem, if one were using Data.Fixed, that is what they should want.</div><div><br></div><div>It sounds like you might just want more accurate approximations, like <a href="http://hackage.haskell.org/package/compensated">http://hackage.haskell.org/package/compensated</a> would offer and not actually fixed point. If that isn't more what you're looking for, I'd be interested in what your use case is for inaccurate fixed point computations was. (Not to imply its bad, I can think of a few common scenarios where fairly inaccurate intermediary results lead to extremely accurate results in the end)</div><div><br></div><div>-davean</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 8:43 PM, Douglas McClean <span dir="ltr"><<a href="mailto:douglas.mcclean@gmail.com" target="_blank">douglas.mcclean@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hello libraries list,<br><br></div><div>(Warning: this whole message may be a waste of time, you may wish to skip it.)<br></div><div><br></div>I'd like to inquire about the possibility of a Floating instance for Data.Fixed. (Unfortunately, not knowing of the existence of this list or the appropriate procedure, I created a trac ticket to ask about this, because that was the only forum I knew of. It's <a href="https://ghc.haskell.org/trac/ghc/ticket/10297" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/10297</a>. Sorry.)<br><br></div>The original idea was along these lines:<br><pre>lift :: (HasResolution a) => (Double -> Double) -> Fixed a -> Fixed a
lift f = realToFrac . f . realToFrac
instance (HasResolution a) => Floating (Fixed a) where
pi = realToFrac pi
sin = lift sin
-- etc, similar lift2 function for (**), logBase</pre>This allows the use of transcendental functions on Fixed values. Conceptually, transcendental functions on fixed point values aren't problematic, and are actually pretty widely used in certain gaming/simulation/signal processing applications.<br><br></div>I've since learned that this may not be a good idea. A commenter (Scott Turner) on the haskell-cafe mailing list astutely raised the issue that because Data.Fixed uses the arbitrary-size Integer type, it's impossible to correctly compute these functions for all possible Fixed values without an arbitrary precision implementation, simply converting through Double like this won't always work.<br><div><div><div><div><div><br></div><div>Sometimes it can be unclear where to draw the line and "stop worrying" about such issues. However, in this case I think it is a good objection, and that a better solution may be to work on advancing Data.Fixed.Binary or a similar library as a home for this functionality, where the size of the values is statically bounded. This has the advantage of also being outside the scope of the base libraries, and thus easier to modify due to the reduced impact.<br><br></div><div>Unfortunately I learned this was probably unworthy of this list's attention after having already filed the trac ticket.<br><br>Unless anyone disagrees and thinks this would be worthwhile, I will close that ticket tomorrow with a note saying where I'm redirecting the effort.<br clear="all"></div><div><div><br><br></div><div>-Doug McClean<br></div></div></div></div></div></div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>