`build (minBound :: Int)` renders as "-0"
- Dominant language
- Haskell
- Stars
- 34
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
We're using text-format-0.3.1.1
```
Data.Text.Buildable Prelude> build (minBound :: Int)
"-0"
```
`Integer` is also affected which is a weirder/worse case:
```
Data.Text.Buildable Prelude> build (-9223372036854775807 :: Integer)
"-9223372036854775807"
Data.Text.Buildable Prelude> build (-9223372036854775808 :: Integer)
"-0"
Data.Text.Buildable Prelude> build (-9223372036854775809 :: Integer)
"-9223372036854775809"
```
The bug is [here](https://github.com/bos/text-format/blob/master/Data/Text/Format/Int.hs#L54):
```
decimal i
| i < 0 = minus <> go (-i) --- < HERE
| otherwise = go i
where
go n | n < 10 = digit n
| otherwise = go (n `quot` 10) <> digit (n `rem` 10)
```
Since `negate minBound` is not representable. In fact I wrote this bug myself a couple weeks ago :) . Will submit a little PR shortly.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.