Skip to content

Number to Text conversion #218

Open
Open
@dschrempf

Description

@dschrempf

Hi,

may I suggest adding conversion functions such as

import qualified Data.Text as T
import qualified Data.Text.Lazy as T (toStrict)
import qualified Data.Text.Lazy.Builder as B
import qualified Data.Text.Lazy.Builder.Int as B
import qualified Data.Text.Lazy.Builder.RealFloat as B

realFloatToText :: RealFloat a => a -> T.Text
realFloatToText = T.toStrict . B.toLazyText . B.realFloat

intToText :: Integral a => a -> T.Text
intToText = T.toStrict . B.toLazyText . B.decimal

to Data.Text because I spent now around two hours in finding a way to convert numbers to Text objects. Maybe there is a better way, in that case it would be nice to have it documented in the main file of the module.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions