@@ -16,8 +16,11 @@ module Ide.Plugin.Conversion (
1616 , toFloatDecimal
1717 , toFloatExpDecimal
1818 , toHexFloat
19+ , intFormats
20+ , fracFormats
1921 , AlternateFormat
2022 , ExtensionNeeded (.. )
23+ , UnderscoreFormatType (.. )
2124) where
2225
2326import Data.List (delete )
@@ -171,17 +174,26 @@ toBinary = toBase showBin_ "0b"
171174 showBin_ = showIntAtBase 2 intToDigit
172175
173176toOctal = toBase showOct " 0o"
177+ data UnderscoreFormatType
178+ = NoUnderscores
179+ | UseUnderscores Int
180+ deriving (Show , Eq )
174181
175182toHex = toBase showHex " 0x"
176183
177184toDecimal :: Integral a => a -> String
178185toDecimal = toBase showInt " "
179186
180- toFloatDecimal :: RealFloat a => a -> String
181- toFloatDecimal val = showFFloat Nothing val " "
187+ intFormats :: Map. Map IntFormatType [ UnderscoreFormatType ]
188+ intFormats = Map. fromList $ map ( \ t -> (t, intFormatUnderscore t)) enumerate
182189
183- toFloatExpDecimal :: RealFloat a => a -> String
184- toFloatExpDecimal val = showEFloat Nothing val " "
190+ intFormatUnderscore :: IntFormatType -> [UnderscoreFormatType ]
191+ intFormatUnderscore formatType = NoUnderscores : map UseUnderscores (case formatType of
192+ IntDecimalFormat -> [3 , 4 ]
193+ HexFormat -> [2 , 4 ]
194+ OctalFormat -> [2 , 4 , 8 ]
195+ BinaryFormat -> [4 ]
196+ NumDecimalFormat -> [3 , 4 ])
185197
186198toHexFloat :: RealFloat a => a -> String
187199toHexFloat val = showHFloat val " "
0 commit comments