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

'TextShow' instance for 'Identity' values.

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

import Data.Functor.Identity (Identity(..))
import TextShow.Classes (TextShow(..), TextShow1(..),
                         showbPrec1, showbUnaryWith)

-- | /Since: 3/
instance TextShow a => TextShow (Identity a) where
    showbPrec :: Int -> Identity a -> Builder
showbPrec = Int -> Identity a -> Builder
forall (f :: * -> *) a.
(TextShow1 f, TextShow a) =>
Int -> f a -> Builder
showbPrec1
    {-# INLINE showbPrec #-}

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