From d082bc939ea07d4ece09035dbdff2cdd20d34c8a Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 25 Nov 2019 23:03:58 +0000 Subject: [PATCH] Fix formatting of negative numbers --- src/Mima/Format/Common.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mima/Format/Common.hs b/src/Mima/Format/Common.hs index b7eafc0..7f4d40a 100644 --- a/src/Mima/Format/Common.hs +++ b/src/Mima/Format/Common.hs @@ -33,12 +33,12 @@ toDec = T.pack . show toHex :: (Integral a, Show a) => a -> T.Text toHex a = T.pack $ showHex a "" --- | @'negative' a@ interprets @a@ as @a - 'maxBound'@ if @a@ is greater than --- @'maxBound' `div` 2@, and as a positive number otherwise. 'minBound' is +-- | @'negative' a@ interprets @a@ as @a - 'maxBound' - 1@ if @a@ is greater +-- than @'maxBound' `div` 2@, and as a positive number otherwise. 'minBound' is -- ignored. negative :: (Integral a, Bounded a, Show a) => (a -> T.Text) -> a -> T.Text negative f a - | a > maxBound `div` 2 = "-" <> f (-(a - maxBound)) + | a > maxBound `div` 2 = "-" <> f (-(a - maxBound - 1)) | otherwise = f a chunkedBy :: T.Text -> Int -> T.Text -> T.Text