Format flag file

This commit is contained in:
Joscha 2019-11-18 09:22:35 +00:00
parent f3c7cdf8b3
commit 5b172ad57f
2 changed files with 48 additions and 0 deletions

19
src/Mima/Format/Common.hs Normal file
View file

@ -0,0 +1,19 @@
module Mima.Format.Common
( toHex
, fixedWidthHex
, fixedWidthHexAddress
) where
import qualified Data.Text as T
import Numeric
import Mima.Word
toHex :: (Integral a, Show a) => a -> T.Text
toHex a = T.pack $ showHex a ""
fixedWidthHex :: (Integral a, Show a) => Int -> a -> T.Text
fixedWidthHex n = T.justifyRight n '0' . toHex
fixedWidthHexAddress :: MimaAddress -> T.Text
fixedWidthHexAddress = fixedWidthHex 5