haskell / haskell/text

Number to Text conversion

Open
#218 8 comments 19 reactions 0 assignees View on GitHub
feature request
Dominant language
Haskell
Stars
421
Forks
163
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.