{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module TextShow.Data.Ratio () where
import GHC.Real (Ratio(..), ratioPrec, ratioPrec1)
import Prelude ()
import Prelude.Compat
import TextShow.Classes (TextShow(..), TextShow1(..), showbParen)
import TextShow.Data.Integral ()
instance TextShow a => TextShow (Ratio a) where
{-# SPECIALIZE instance TextShow Rational #-}
showbPrec p (numer :% denom) = showbParen (p > ratioPrec) $
showbPrec ratioPrec1 numer
<> " % "
<> showbPrec ratioPrec1 denom
{-# INLINE showbPrec #-}
instance TextShow1 Ratio where
liftShowbPrec sp _ p (numer :% denom) = showbParen (p > ratioPrec) $
sp ratioPrec1 numer
<> " % "
<> sp ratioPrec1 denom
{-# INLINE liftShowbPrec #-}