{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds         #-}
{-# LANGUAGE TemplateHaskell   #-}

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

'TextShow' instances for 'Const' and 'ZipList'.

/Since: 2/
-}
module TextShow.Control.Applicative () where

import Control.Applicative (Const(..), ZipList)

import Data.Text.Lazy.Builder (Builder)

import TextShow.Classes (TextShow(..), TextShow1(..),
                         TextShow2(..), showbUnaryWith)
import TextShow.Data.List ()
import TextShow.TH.Internal (deriveTextShow, deriveTextShow1)

-- | /Since: 2/
instance TextShow a => TextShow (Const a b) where
    showbPrec :: Int -> Const a b -> Builder
showbPrec = (Int -> a -> Builder) -> Int -> Const a b -> Builder
forall k a (b :: k).
(Int -> a -> Builder) -> Int -> Const a b -> Builder
liftShowbConstPrec Int -> a -> Builder
forall a. TextShow a => Int -> a -> Builder
showbPrec

-- | /Since: 2/
instance TextShow a => TextShow1 (Const a) where
    liftShowbPrec :: (Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> Const a a -> Builder
liftShowbPrec Int -> a -> Builder
_ [a] -> Builder
_ = (Int -> a -> Builder) -> Int -> Const a a -> Builder
forall k a (b :: k).
(Int -> a -> Builder) -> Int -> Const a b -> Builder
liftShowbConstPrec Int -> a -> Builder
forall a. TextShow a => Int -> a -> Builder
showbPrec

-- | /Since: 2/
instance TextShow2 Const where
    liftShowbPrec2 :: (Int -> a -> Builder)
-> ([a] -> Builder)
-> (Int -> b -> Builder)
-> ([b] -> Builder)
-> Int
-> Const a b
-> Builder
liftShowbPrec2 Int -> a -> Builder
sp [a] -> Builder
_ Int -> b -> Builder
_ [b] -> Builder
_  = (Int -> a -> Builder) -> Int -> Const a b -> Builder
forall k a (b :: k).
(Int -> a -> Builder) -> Int -> Const a b -> Builder
liftShowbConstPrec Int -> a -> Builder
sp

liftShowbConstPrec :: (Int -> a -> Builder) -> Int -> Const a b -> Builder
liftShowbConstPrec :: (Int -> a -> Builder) -> Int -> Const a b -> Builder
liftShowbConstPrec Int -> a -> Builder
sp Int
p (Const a
x) = (Int -> a -> Builder) -> Builder -> Int -> a -> Builder
forall a. (Int -> a -> Builder) -> Builder -> Int -> a -> Builder
showbUnaryWith Int -> a -> Builder
sp Builder
"Const" Int
p a
x
{-# INLINE liftShowbConstPrec #-}

-- | /Since: 2/
$(deriveTextShow  ''ZipList)
-- | /Since: 2/
$(deriveTextShow1 ''ZipList)