Data.Fixed Missing E4, E5, etc

Merijn Verstraaten merijn at inconsistent.nl
Wed Aug 3 15:46:37 UTC 2016


Hi Andrew,

Data.Fixed actually already provides all the tools you need to support any arbitrary precision. As such, I don't see the need to add obscure precisions to the library in addition to the existing common ones. Using Data.Fixed with a 4 digit precision like you want can be achieved in 3 lines of code in you geolite library. Simply define:

data MyPrecision
instance HasResolution MyPrecision where
    resolution _ = 4

and use "Fixed MyPrecision" as type in your library. As you can see in the haddocks, the Num, Real, RealFrac, etc. instances work for any arbitrary instance of HasResolution.

Cheers,
Merijn

> On 3 Aug 2016, at 13:57, Andrew Martin <andrew.thaddeus at gmail.com> wrote:
> 
> I've been working on a library for parsing geolite's GeoIP csv file
> (http://hackage.haskell.org/package/geolite-csv-0.2/docs/Geolite-Types.html).
> In this file, the latitude and longitude are always given to four
> decimal points of precision. It seems like the Fixed data type (from
> Data.Fixed in base) is the best choice for representing this.
> 
> However, the precision levels provided are:
> 
> - E0
> - E1
> - E2
> - E3
> - E6
> - E9
> - E12
> 
> I would like to propose adding all of the missing ones into Data.Fixed
> as well. Even though needed a four-decimal-point-precision number is
> uncommon, it's not unheard of. Admittedly, the precision offered by E11
> seems unlikely to ever be needed, but I think it would be nice for
> completeness. I would be happy to PR this if others agree that it's a
> good idea.
> 
> -Andrew Martin
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160803/53779c22/attachment.sig>


More information about the Libraries mailing list