Skip to content

Overhaul Data.ByteString.Builder.RealFloat #636

@BebeSparkelSparkel

Description

@BebeSparkelSparkel

I have created the following PRs but they seem to be intermingled and perhaps a larger pull would be better
#632
#633
#634

I propose the following

  1. combine the logic of formatFloat and formatDouble into formatFloating :: FloatFormat -> a -> Builder since they have the same logic and use classes to get their specific functions based on the floating type. Continuing exporting the formatFloat and formatDouble interface functions for compatibility.
  2. Replace the constructor of FloatFormat to the constructors of FormatMode and remove the type FormatMode because the precision (Maybe Int) is not used and can be included as a parameter of the constructors
  3. FScientific should have a Char for specifying a lower or upper E
  4. FStandard should have a Maybe Int for the precision
  5. FGeneric should have a Char for specifying a lower or upper E, and two Ints for the inclusive exponent range for printing the standard notation
  6. Allow custom strings for special values +-Infinity +-0 NaN with data SpecialStrings = {..}
  7. remove specialStr and use toCharsNonNumbersAndZero instead because they duplicate logic and it is faster to evaluate
  8. I am unsure if this is optimized away but the case statement that selects the format should not be executed for every floating number to be printed. If not, the \f -> ... should be defined after the case statement and not before.

None of these changes should cause changes to the existing interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions