Ticket #8188: thPprRationalL.patch

File thPprRationalL.patch, 909 bytes (added by YoshikuniJujo, 11 months ago)

git diff

  • Language/Haskell/TH/Ppr.hs

    diff --git a/Language/Haskell/TH/Ppr.hs b/Language/Haskell/TH/Ppr.hs
    index 78d422a..563c7f7 100644
    a b import Language.Haskell.TH.Syntax 
    1212import Data.Word ( Word8 ) 
    1313import Data.Char ( toLower, chr ) 
    1414import GHC.Show  ( showMultiLineString ) 
     15import Data.Ratio ( numerator, denominator ) 
    1516 
    1617nestDepth :: Int 
    1718nestDepth = 4 
    pprLit i (IntegerL x) = parensIf (i > noPrec && x < 0) (integer x) 
    189190pprLit _ (CharL c)       = text (show c) 
    190191pprLit _ (StringL s)     = pprString s 
    191192pprLit _ (StringPrimL s) = pprString (bytesToString s) <> char '#' 
    192 pprLit i (RationalL rat) = parensIf (i > noPrec) $ rational rat 
     193pprLit i (RationalL rat) = parensIf (i > noPrec) $ 
     194        integer (numerator rat) <+> char '/' <+> integer (denominator rat) 
    193195 
    194196bytesToString :: [Word8] -> String 
    195197bytesToString = map (chr . fromIntegral)