haskell / haskell/text

Padded decimal and hexadecimal text builders

未关闭
#163 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
feature request
主要语言
Haskell
星标
421
派生
163
PR 合并指标
30 天内没有已合并 PR

描述

In `Data.Text.Lazy.Builder.Int`, the functions `decimal` and `hexadecimal` are available. Sometimes, I need to zero pad my decimal and hexadecimal representations to a certain length. I propose adding the following two functions to this module:

```
paddedDecimal :: Integral a => Int -> a -> Builder
paddedHexadecimal :: Integral a => Int -> a -> Builder
```

The behaviors of these would be:
- The padding occurs on the left.
- The padding adds zeroes until that cause the builder to be of the desired length.
- The padding happens after the minus sign in the event that the number is negative.

Examples of expected behavior:

```
> paddedDecimal 3 5
005
> paddedDecimal 6 (-103)
-000103
> paddedDecimal 2 1039
1039
> paddedDecimal (-5) 1
1
```

If this would be a welcome addition, I am already familiar with the integral text builder code, and I would be happy to add these functions. The only place where I am uncertain of how to proceed would be writing a performant specialization for `Integer`.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。