{-# LANGUAGE CPP #-}
#if MIN_VERSION_base(4,8,0)
{-# LANGUAGE MagicHash #-}
#endif
{-# OPTIONS_GHC -fno-warn-orphans #-}
module TextShow.Numeric.Natural () where
#if MIN_VERSION_base(4,8,0)
import GHC.Integer.GMP.Internals (Integer(..))
import GHC.Natural (Natural(..))
import GHC.Types (Word(..))
#else
import Numeric.Natural.Compat (Natural)
#endif
import TextShow.Classes (TextShow(..))
import TextShow.Data.Integral ()
instance TextShow Natural where
#if MIN_VERSION_base(4,8,0)
showbPrec :: Int -> Natural -> Builder
showbPrec _ (NatS# w# :: GmpLimb#
w#) = Word -> Builder
forall a. TextShow a => a -> Builder
showb (Word -> Builder) -> Word -> Builder
forall a b. (a -> b) -> a -> b
$ GmpLimb# -> Word
W# GmpLimb#
w#
showbPrec p :: Int
p (NatJ# bn :: BigNat
bn) = Int -> Integer -> Builder
forall a. TextShow a => Int -> a -> Builder
showbPrec Int
p (Integer -> Builder) -> Integer -> Builder
forall a b. (a -> b) -> a -> b
$ BigNat -> Integer
Jp# BigNat
bn
#else
showbPrec p = showbPrec p . toInteger
{-# INLINE showbPrec #-}
#endif