Closed Icelandjack closed 10 years ago
One issue is that showIntAtBase
adds Show
and Integral
constraints while hex
only adds Integral
.
Thoughts:
hex
as it's a fast implementation.prefixBase
, if that doesn't defy the point by being longer.bin
and oct
would be consistent with having hex
as these three are after all special bases in computing.Show
constraint, it's unfortunate but we can overcome it if it grates later.I'll definitely accept the base
combinator and bin
and oct
.
Yes I'll leave hex
alone and Show
doesn't seem to be an issue.
Currently base-16 is the only formatter supported like in
text-format
— unless there is some reason not to it's easy to define other bases usingshowIntAtBase
fromNumeric
(similar to Numeric.Lens):I made the following as a simple proof of concept, if you're okay with adding it to the project I'll submit a request:
with
Then specialized bases would be trivially implemented:
As efficiency is concerned,
text-format
doesn't exportinteger
but a more efficient version for arbitrary bases or specialized for certain base likehexadecimal
can be added later.I'm not sure about the names of the prime functions, if this looks fine I'll add it.