Padded decimal and hexadecimal text builders
- 主要语言
- 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 还没有评估数据。