{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-|
Module:      TextShow.Data.Ord
Copyright:   (C) 2014-2017 Ryan Scott
License:     BSD-style (see the file LICENSE)
Maintainer:  Ryan Scott
Stability:   Provisional
Portability: GHC

'TextShow' instances for 'Ordering' and 'Down'.

/Since: 2/
-}
module TextShow.Data.Ord () where

import GHC.Exts (Down(..))

import TextShow.Classes ( TextShow(..), TextShow1(..)
                        , showbPrec1, showbUnaryWith )
import TextShow.TH.Internal (deriveTextShow)

-- | This instance would be equivalent to a derived 'TextShow' instance
-- if the 'getDown' field were removed.
--
-- /Since: 2/
instance TextShow a => TextShow (Down a) where
    showbPrec :: Int -> Down a -> Builder
showbPrec = Int -> Down a -> Builder
forall (f :: * -> *) a.
(TextShow1 f, TextShow a) =>
Int -> f a -> Builder
showbPrec1
    {-# INLINE showbPrec #-}

-- | This instance would be equivalent to a derived 'TextShow1' instance
-- if the 'getDown' field were removed.
--
-- /Since: 2/
instance TextShow1 Down where
    liftShowbPrec :: forall a.
(Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> Down a -> Builder
liftShowbPrec Int -> a -> Builder
sp [a] -> Builder
_ Int
p (Down a
x) = (Int -> a -> Builder) -> Builder -> Int -> a -> Builder
forall a. (Int -> a -> Builder) -> Builder -> Int -> a -> Builder
showbUnaryWith Int -> a -> Builder
sp Builder
"Down" Int
p a
x
    {-# INLINE liftShowbPrec #-}

-- | /Since: 2/
$(deriveTextShow ''Ordering)