diff options
Diffstat (limited to 'compiler/utils/Outputable.hs')
-rw-r--r-- | compiler/utils/Outputable.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 259b554c23..64b3542706 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -22,7 +22,7 @@ module Outputable ( empty, isEmpty, nest, char, text, ftext, ptext, ztext, - int, intWithCommas, integer, float, double, rational, + int, intWithCommas, integer, float, double, rational, doublePrec, parens, cparen, brackets, braces, quotes, quote, doubleQuotes, angleBrackets, paBrackets, semi, comma, colon, dcolon, space, equals, dot, vbar, @@ -111,6 +111,7 @@ import Data.Word import System.IO ( Handle ) import System.FilePath import Text.Printf +import Numeric (showFFloat) import Data.Graph (SCC(..)) import GHC.Fingerprint @@ -508,6 +509,11 @@ float n = docToSDoc $ Pretty.float n double n = docToSDoc $ Pretty.double n rational n = docToSDoc $ Pretty.rational n +-- | @doublePrec p n@ shows a floating point number @n@ with @p@ +-- digits of precision after the decimal point. +doublePrec :: Int -> Double -> SDoc +doublePrec p n = text (showFFloat (Just p) n "") + parens, braces, brackets, quotes, quote, paBrackets, doubleQuotes, angleBrackets :: SDoc -> SDoc |