{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE DeriveFoldable        #-}
{-# LANGUAGE DeriveFunctor         #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE DeriveTraversable     #-}
{-# LANGUAGE EmptyCase             #-}
{-# LANGUAGE EmptyDataDecls        #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE GADTs                 #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE PolyKinds             #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE StandaloneDeriving    #-}
{-# LANGUAGE TypeOperators         #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE TypeSynonymInstances  #-}
{-# LANGUAGE UndecidableInstances  #-}

#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE DeriveLift            #-}
#endif

#if __GLASGOW_HASKELL__ >= 806
{-# LANGUAGE QuantifiedConstraints #-}
#endif

{-|
Module:      TextShow.Generic
Copyright:   (C) 2014-2017 Ryan Scott
License:     BSD-style (see the file LICENSE)
Maintainer:  Ryan Scott
Stability:   Provisional
Portability: GHC

Generic versions of 'TextShow' and 'TextShow1' class functions, as an alternative to
"TextShow.TH", which uses Template Haskell. Because there is no 'Generic2'
class, 'TextShow2' cannot be implemented generically.

This implementation is loosely based off of the @Generics.Deriving.Show@ module
from the @generic-deriving@ library.

/Since: 2/
-}
module TextShow.Generic (
      -- * Generic adapter newtypes
      FromGeneric(..)
    , FromGeneric1(..)

      -- * Generic @show@ functions
      -- $generics
    , genericShowt
    , genericShowtl
    , genericShowtPrec
    , genericShowtlPrec
    , genericShowtList
    , genericShowtlList
    , genericShowb
    , genericShowbPrec
    , genericShowbList
    , genericPrintT
    , genericPrintTL
    , genericHPrintT
    , genericHPrintTL
    , genericLiftShowbPrec
    , genericShowbPrec1
      -- * Internals
      -- ** 'Builder'
    , GTextShowB(..)
    , GTextShowConB(..)
    , GTextShowB1(..)
    , GTextShowConB1(..)
      -- ** Strict 'TS.Text'
    , GTextShowT(..)
    , GTextShowConT(..)
    , GTextShowT1(..)
    , GTextShowConT1(..)
      -- ** Lazy 'TL.Text'
    , GTextShowTL(..)
    , GTextShowConTL(..)
    , GTextShowTL1(..)
    , GTextShowConTL1(..)
      -- ** Other internals
    , IsNullary(..)
    , ConType(..)
    ) where

import           Data.Data (Data, Typeable)
import qualified Data.Text    as TS (Text, pack, singleton)
import qualified Data.Text.IO as TS (putStrLn, hPutStrLn)
import qualified Data.Text.Lazy    as TL (Text, pack, singleton)
import qualified Data.Text.Lazy.IO as TL (putStrLn, hPutStrLn)
import qualified Data.Text.Lazy.Builder as TB (fromString, singleton)
import           Data.Text.Lazy.Builder (Builder)

import           Generics.Deriving.Base
#if !defined(__LANGUAGE_DERIVE_GENERIC1__)
import qualified Generics.Deriving.TH as Generics
#endif

import           GHC.Exts (Char(C#), Double(D#), Float(F#), Int(I#), Word(W#))
import           GHC.Show (appPrec, appPrec1)

import           Language.Haskell.TH.Lift

import           Prelude ()
import           Prelude.Compat

import           System.IO (Handle)

import           TextShow.Classes (TextShow(..), TextShow1(..),
                                   showbListWith, showbParen, showbSpace,
                                   showtListWith, showtParen, showtSpace,
                                   showtlListWith, showtlParen, showtlSpace,
                                   liftShowtPrec, liftShowtlPrec)
import           TextShow.Instances ()
import           TextShow.TH.Internal (deriveTextShow)
import           TextShow.Utils (isInfixDataCon, isSymVar, isTupleString)

{- $generics

'TextShow' instances can be easily defined for data types that are 'Generic' instances.
If you are using GHC 8.6 or later, the easiest way to do this is to use the
@DerivingVia@ extension.

@
{-# LANGUAGE DeriveGeneric, DerivingVia #-}
import GHC.Generics
import TextShow
import TextShow.Generic

data D a = D a
  deriving ('Generic', 'Generic1')
  deriving 'TextShow'  via 'FromGeneric'  (D a)
  deriving 'TextShow1' via 'FromGeneric1' D
@

Or, if you are using a version of GHC older than 8.6, one can alternatively
define these instances like so:

@
instance 'TextShow' a => 'TextShow' (D a) where
    'showbPrec' = 'genericShowbPrec'

instance 'TextShow1' D where
    'liftShowbPrec' = 'genericLiftShowbPrec'
@
-}

-- | An adapter newtype, suitable for @DerivingVia@.
-- The 'TextShow' instance for 'FromGeneric' leverages a 'Generic'-based
-- default. That is,
--
-- @
-- 'showbPrec' p ('FromGeneric' x) = 'genericShowbPrec' p x
-- @
--
-- /Since: 3.7.4/
newtype FromGeneric a = FromGeneric { forall a. FromGeneric a -> a
fromGeneric :: a }
  deriving ( FromGeneric a -> DataType
FromGeneric a -> Constr
forall {a}. Data a => Typeable (FromGeneric a)
forall a. Data a => FromGeneric a -> DataType
forall a. Data a => FromGeneric a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> FromGeneric a -> FromGeneric a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> FromGeneric a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> FromGeneric a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FromGeneric a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FromGeneric a -> c (FromGeneric a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (FromGeneric a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FromGeneric a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FromGeneric a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FromGeneric a -> c (FromGeneric a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (FromGeneric a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> FromGeneric a -> m (FromGeneric a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FromGeneric a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> FromGeneric a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> FromGeneric a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> FromGeneric a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FromGeneric a -> r
gmapT :: (forall b. Data b => b -> b) -> FromGeneric a -> FromGeneric a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> FromGeneric a -> FromGeneric a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FromGeneric a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FromGeneric a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (FromGeneric a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (FromGeneric a))
dataTypeOf :: FromGeneric a -> DataType
$cdataTypeOf :: forall a. Data a => FromGeneric a -> DataType
toConstr :: FromGeneric a -> Constr
$ctoConstr :: forall a. Data a => FromGeneric a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FromGeneric a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FromGeneric a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FromGeneric a -> c (FromGeneric a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FromGeneric a -> c (FromGeneric a)
Data
           , FromGeneric a -> FromGeneric a -> Bool
forall a. Eq a => FromGeneric a -> FromGeneric a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FromGeneric a -> FromGeneric a -> Bool
$c/= :: forall a. Eq a => FromGeneric a -> FromGeneric a -> Bool
== :: FromGeneric a -> FromGeneric a -> Bool
$c== :: forall a. Eq a => FromGeneric a -> FromGeneric a -> Bool
Eq
           , forall a. Eq a => a -> FromGeneric a -> Bool
forall a. Num a => FromGeneric a -> a
forall a. Ord a => FromGeneric a -> a
forall m. Monoid m => FromGeneric m -> m
forall a. FromGeneric a -> Bool
forall a. FromGeneric a -> Int
forall a. FromGeneric a -> [a]
forall a. (a -> a -> a) -> FromGeneric a -> a
forall m a. Monoid m => (a -> m) -> FromGeneric a -> m
forall b a. (b -> a -> b) -> b -> FromGeneric a -> b
forall a b. (a -> b -> b) -> b -> FromGeneric a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => FromGeneric a -> a
$cproduct :: forall a. Num a => FromGeneric a -> a
sum :: forall a. Num a => FromGeneric a -> a
$csum :: forall a. Num a => FromGeneric a -> a
minimum :: forall a. Ord a => FromGeneric a -> a
$cminimum :: forall a. Ord a => FromGeneric a -> a
maximum :: forall a. Ord a => FromGeneric a -> a
$cmaximum :: forall a. Ord a => FromGeneric a -> a
elem :: forall a. Eq a => a -> FromGeneric a -> Bool
$celem :: forall a. Eq a => a -> FromGeneric a -> Bool
length :: forall a. FromGeneric a -> Int
$clength :: forall a. FromGeneric a -> Int
null :: forall a. FromGeneric a -> Bool
$cnull :: forall a. FromGeneric a -> Bool
toList :: forall a. FromGeneric a -> [a]
$ctoList :: forall a. FromGeneric a -> [a]
foldl1 :: forall a. (a -> a -> a) -> FromGeneric a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> FromGeneric a -> a
foldr1 :: forall a. (a -> a -> a) -> FromGeneric a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> FromGeneric a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> FromGeneric a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> FromGeneric a -> b
foldl :: forall b a. (b -> a -> b) -> b -> FromGeneric a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> FromGeneric a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> FromGeneric a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> FromGeneric a -> b
foldr :: forall a b. (a -> b -> b) -> b -> FromGeneric a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> FromGeneric a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> FromGeneric a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> FromGeneric a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> FromGeneric a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> FromGeneric a -> m
fold :: forall m. Monoid m => FromGeneric m -> m
$cfold :: forall m. Monoid m => FromGeneric m -> m
Foldable
           , forall a b. a -> FromGeneric b -> FromGeneric a
forall a b. (a -> b) -> FromGeneric a -> FromGeneric b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> FromGeneric b -> FromGeneric a
$c<$ :: forall a b. a -> FromGeneric b -> FromGeneric a
fmap :: forall a b. (a -> b) -> FromGeneric a -> FromGeneric b
$cfmap :: forall a b. (a -> b) -> FromGeneric a -> FromGeneric b
Functor
           , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (FromGeneric a) x -> FromGeneric a
forall a x. FromGeneric a -> Rep (FromGeneric a) x
$cto :: forall a x. Rep (FromGeneric a) x -> FromGeneric a
$cfrom :: forall a x. FromGeneric a -> Rep (FromGeneric a) x
Generic
           , forall a. Rep1 FromGeneric a -> FromGeneric a
forall a. FromGeneric a -> Rep1 FromGeneric a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 FromGeneric a -> FromGeneric a
$cfrom1 :: forall a. FromGeneric a -> Rep1 FromGeneric a
Generic1
           , FromGeneric a -> FromGeneric a -> Bool
FromGeneric a -> FromGeneric a -> Ordering
FromGeneric a -> FromGeneric a -> FromGeneric a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (FromGeneric a)
forall a. Ord a => FromGeneric a -> FromGeneric a -> Bool
forall a. Ord a => FromGeneric a -> FromGeneric a -> Ordering
forall a. Ord a => FromGeneric a -> FromGeneric a -> FromGeneric a
min :: FromGeneric a -> FromGeneric a -> FromGeneric a
$cmin :: forall a. Ord a => FromGeneric a -> FromGeneric a -> FromGeneric a
max :: FromGeneric a -> FromGeneric a -> FromGeneric a
$cmax :: forall a. Ord a => FromGeneric a -> FromGeneric a -> FromGeneric a
>= :: FromGeneric a -> FromGeneric a -> Bool
$c>= :: forall a. Ord a => FromGeneric a -> FromGeneric a -> Bool
> :: FromGeneric a -> FromGeneric a -> Bool
$c> :: forall a. Ord a => FromGeneric a -> FromGeneric a -> Bool
<= :: FromGeneric a -> FromGeneric a -> Bool
$c<= :: forall a. Ord a => FromGeneric a -> FromGeneric a -> Bool
< :: FromGeneric a -> FromGeneric a -> Bool
$c< :: forall a. Ord a => FromGeneric a -> FromGeneric a -> Bool
compare :: FromGeneric a -> FromGeneric a -> Ordering
$ccompare :: forall a. Ord a => FromGeneric a -> FromGeneric a -> Ordering
Ord
           , ReadPrec [FromGeneric a]
ReadPrec (FromGeneric a)
ReadS [FromGeneric a]
forall a. Read a => ReadPrec [FromGeneric a]
forall a. Read a => ReadPrec (FromGeneric a)
forall a. Read a => Int -> ReadS (FromGeneric a)
forall a. Read a => ReadS [FromGeneric a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FromGeneric a]
$creadListPrec :: forall a. Read a => ReadPrec [FromGeneric a]
readPrec :: ReadPrec (FromGeneric a)
$creadPrec :: forall a. Read a => ReadPrec (FromGeneric a)
readList :: ReadS [FromGeneric a]
$creadList :: forall a. Read a => ReadS [FromGeneric a]
readsPrec :: Int -> ReadS (FromGeneric a)
$creadsPrec :: forall a. Read a => Int -> ReadS (FromGeneric a)
Read
           , Int -> FromGeneric a -> ShowS
forall a. Show a => Int -> FromGeneric a -> ShowS
forall a. Show a => [FromGeneric a] -> ShowS
forall a. Show a => FromGeneric a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FromGeneric a] -> ShowS
$cshowList :: forall a. Show a => [FromGeneric a] -> ShowS
show :: FromGeneric a -> String
$cshow :: forall a. Show a => FromGeneric a -> String
showsPrec :: Int -> FromGeneric a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> FromGeneric a -> ShowS
Show
           , Functor FromGeneric
Foldable FromGeneric
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
FromGeneric (m a) -> m (FromGeneric a)
forall (f :: * -> *) a.
Applicative f =>
FromGeneric (f a) -> f (FromGeneric a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FromGeneric a -> m (FromGeneric b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FromGeneric a -> f (FromGeneric b)
sequence :: forall (m :: * -> *) a.
Monad m =>
FromGeneric (m a) -> m (FromGeneric a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
FromGeneric (m a) -> m (FromGeneric a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FromGeneric a -> m (FromGeneric b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FromGeneric a -> m (FromGeneric b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
FromGeneric (f a) -> f (FromGeneric a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
FromGeneric (f a) -> f (FromGeneric a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FromGeneric a -> f (FromGeneric b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FromGeneric a -> f (FromGeneric b)
Traversable
           , Typeable
#if __GLASGOW_HASKELL__ >= 800
           , forall a (m :: * -> *). (Lift a, Quote m) => FromGeneric a -> m Exp
forall a (m :: * -> *).
(Lift a, Quote m) =>
FromGeneric a -> Code m (FromGeneric a)
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FromGeneric a -> m Exp
forall (m :: * -> *).
Quote m =>
FromGeneric a -> Code m (FromGeneric a)
liftTyped :: forall (m :: * -> *).
Quote m =>
FromGeneric a -> Code m (FromGeneric a)
$cliftTyped :: forall a (m :: * -> *).
(Lift a, Quote m) =>
FromGeneric a -> Code m (FromGeneric a)
lift :: forall (m :: * -> *). Quote m => FromGeneric a -> m Exp
$clift :: forall a (m :: * -> *). (Lift a, Quote m) => FromGeneric a -> m Exp
Lift
#endif
           )

-- | /Since: 3.7.4/
instance (Generic a, GTextShowB (Rep a ())) => TextShow (FromGeneric a) where
  showbPrec :: Int -> FromGeneric a -> Builder
showbPrec Int
p = forall a. (Generic a, GTextShowB (Rep a ())) => Int -> a -> Builder
genericShowbPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. FromGeneric a -> a
fromGeneric

-- | An adapter newtype, suitable for @DerivingVia@.
-- The 'TextShow1' instance for 'FromGeneric1' leverages a 'Generic1'-based
-- default. That is,
--
-- @
-- 'liftShowbPrec' sp sl p ('FromGeneric1' x) = 'genericLiftShowbPrec' sp sl p x
-- @
--
-- /Since: 3.7.4/
newtype FromGeneric1 f a = FromGeneric1 { forall {k} (f :: k -> *) (a :: k). FromGeneric1 f a -> f a
fromGeneric1 :: f a }
  deriving ( FromGeneric1 f a -> FromGeneric1 f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
/= :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
== :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
Eq
           , FromGeneric1 f a -> FromGeneric1 f a -> Bool
FromGeneric1 f a -> FromGeneric1 f a -> Ordering
FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {f :: k -> *} {a :: k}.
Ord (f a) =>
Eq (FromGeneric1 f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
min :: FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
max :: FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> FromGeneric1 f a
>= :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
> :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
<= :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
< :: FromGeneric1 f a -> FromGeneric1 f a -> Bool
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Bool
compare :: FromGeneric1 f a -> FromGeneric1 f a -> Ordering
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
FromGeneric1 f a -> FromGeneric1 f a -> Ordering
Ord
           , ReadPrec [FromGeneric1 f a]
ReadPrec (FromGeneric1 f a)
ReadS [FromGeneric1 f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [FromGeneric1 f a]
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (FromGeneric1 f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (FromGeneric1 f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [FromGeneric1 f a]
readListPrec :: ReadPrec [FromGeneric1 f a]
$creadListPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [FromGeneric1 f a]
readPrec :: ReadPrec (FromGeneric1 f a)
$creadPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (FromGeneric1 f a)
readList :: ReadS [FromGeneric1 f a]
$creadList :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [FromGeneric1 f a]
readsPrec :: Int -> ReadS (FromGeneric1 f a)
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (FromGeneric1 f a)
Read
           , Int -> FromGeneric1 f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> FromGeneric1 f a -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
[FromGeneric1 f a] -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
FromGeneric1 f a -> String
showList :: [FromGeneric1 f a] -> ShowS
$cshowList :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
[FromGeneric1 f a] -> ShowS
show :: FromGeneric1 f a -> String
$cshow :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
FromGeneric1 f a -> String
showsPrec :: Int -> FromGeneric1 f a -> ShowS
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> FromGeneric1 f a -> ShowS
Show
           , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (a :: k) x.
Rep (FromGeneric1 f a) x -> FromGeneric1 f a
forall k (f :: k -> *) (a :: k) x.
FromGeneric1 f a -> Rep (FromGeneric1 f a) x
$cto :: forall k (f :: k -> *) (a :: k) x.
Rep (FromGeneric1 f a) x -> FromGeneric1 f a
$cfrom :: forall k (f :: k -> *) (a :: k) x.
FromGeneric1 f a -> Rep (FromGeneric1 f a) x
Generic
#if defined(__LANGUAGE_DERIVE_GENERIC1__)
           , Generic1
#endif
#if __GLASGOW_HASKELL__ >= 800
           , forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Lift (f a), Quote m) =>
FromGeneric1 f a -> m Exp
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Lift (f a), Quote m) =>
FromGeneric1 f a -> Code m (FromGeneric1 f a)
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => FromGeneric1 f a -> m Exp
forall (m :: * -> *).
Quote m =>
FromGeneric1 f a -> Code m (FromGeneric1 f a)
liftTyped :: forall (m :: * -> *).
Quote m =>
FromGeneric1 f a -> Code m (FromGeneric1 f a)
$cliftTyped :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Lift (f a), Quote m) =>
FromGeneric1 f a -> Code m (FromGeneric1 f a)
lift :: forall (m :: * -> *). Quote m => FromGeneric1 f a -> m Exp
$clift :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Lift (f a), Quote m) =>
FromGeneric1 f a -> m Exp
Lift
#endif
           )

deriving instance Foldable    f => Foldable    (FromGeneric1 f)
deriving instance Functor     f => Functor     (FromGeneric1 f)
deriving instance Traversable f => Traversable (FromGeneric1 f)
deriving instance Typeable FromGeneric1
deriving instance ( Data (f a), Typeable f, Typeable a
                  ) => Data (FromGeneric1 f (a :: *))

-- | /Since: 3.10/
instance (Generic1 f, GTextShowB (Rep1 f a)) => TextShow (FromGeneric1 f a) where
  showbPrec :: Int -> FromGeneric1 f a -> Builder
showbPrec Int
p = forall a. GTextShowB a => Int -> a -> Builder
gShowbPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). FromGeneric1 f a -> f a
fromGeneric1

-- | /Since: 3.7.4/
instance ( Generic1 f, GTextShowB1 (Rep1 f)
#if __GLASGOW_HASKELL__ >= 806 && __GLASGOW_HASKELL__ < 902
           -- Unfortunately, the quantified superclass for GTextShowB1 doesn't
           -- work on pre-9.2 versions of GHC, perhaps due to
           -- https://gitlab.haskell.org/ghc/ghc/-/issues/14860#note_454218.
           -- Fortunately, we can make GHC come to its senses by using an
           -- equality constraint.
         , g ~ Rep1 f, forall a. TextShow a => GTextShowB (g a)
#endif
         ) => TextShow1 (FromGeneric1 f) where
  liftShowbPrec :: forall a.
(Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> FromGeneric1 f a -> Builder
liftShowbPrec Int -> a -> Builder
sp [a] -> Builder
sl Int
p = forall (f :: * -> *) a.
(Generic1 f, GTextShowB1 (Rep1 f)) =>
(Int -> a -> Builder) -> ([a] -> Builder) -> Int -> f a -> Builder
genericLiftShowbPrec Int -> a -> Builder
sp [a] -> Builder
sl Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). FromGeneric1 f a -> f a
fromGeneric1

-- | A 'Generic' implementation of 'showt'.
--
-- /Since: 2/
genericShowt :: (Generic a, GTextShowT (Rep a ())) => a -> TS.Text
genericShowt :: forall a. (Generic a, GTextShowT (Rep a ())) => a -> Text
genericShowt = forall a. (Generic a, GTextShowT (Rep a ())) => Int -> a -> Text
genericShowtPrec Int
0

-- | A 'Generic' implementation of 'showtl'.
--
-- /Since: 2/
genericShowtl :: (Generic a, GTextShowTL (Rep a ())) => a -> TL.Text
genericShowtl :: forall a. (Generic a, GTextShowTL (Rep a ())) => a -> Text
genericShowtl = forall a. (Generic a, GTextShowTL (Rep a ())) => Int -> a -> Text
genericShowtlPrec Int
0

-- | A 'Generic' implementation of 'showPrect'.
--
-- /Since: 2/
genericShowtPrec :: (Generic a, GTextShowT (Rep a ())) => Int -> a -> TS.Text
genericShowtPrec :: forall a. (Generic a, GTextShowT (Rep a ())) => Int -> a -> Text
genericShowtPrec Int
p = forall a. GTextShowT a => Int -> a -> Text
gShowtPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Generic a => a -> Rep a ()
fromRepUnit

-- | A 'Generic' implementation of 'showtlPrec'.
--
-- /Since: 2/
genericShowtlPrec :: (Generic a, GTextShowTL (Rep a ())) => Int -> a -> TL.Text
genericShowtlPrec :: forall a. (Generic a, GTextShowTL (Rep a ())) => Int -> a -> Text
genericShowtlPrec Int
p = forall a. GTextShowTL a => Int -> a -> Text
gShowtlPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Generic a => a -> Rep a ()
fromRepUnit

-- | A 'Generic' implementation of 'showtList'.
--
-- /Since: 2/
genericShowtList :: (Generic a, GTextShowT (Rep a ())) => [a] -> TS.Text
genericShowtList :: forall a. (Generic a, GTextShowT (Rep a ())) => [a] -> Text
genericShowtList = forall a. (a -> Text) -> [a] -> Text
showtListWith forall a. (Generic a, GTextShowT (Rep a ())) => a -> Text
genericShowt

-- | A 'Generic' implementation of 'showtlList'.
--
-- /Since: 2/
genericShowtlList :: (Generic a, GTextShowTL (Rep a ())) => [a] -> TL.Text
genericShowtlList :: forall a. (Generic a, GTextShowTL (Rep a ())) => [a] -> Text
genericShowtlList = forall a. (a -> Text) -> [a] -> Text
showtlListWith forall a. (Generic a, GTextShowTL (Rep a ())) => a -> Text
genericShowtl

-- | A 'Generic' implementation of 'showb'.
--
-- /Since: 2/
genericShowb :: (Generic a, GTextShowB (Rep a ())) => a -> Builder
genericShowb :: forall a. (Generic a, GTextShowB (Rep a ())) => a -> Builder
genericShowb = forall a. (Generic a, GTextShowB (Rep a ())) => Int -> a -> Builder
genericShowbPrec Int
0

-- | A 'Generic' implementation of 'showbPrec'.
--
-- /Since: 2/
genericShowbPrec :: (Generic a, GTextShowB (Rep a ())) => Int -> a -> Builder
genericShowbPrec :: forall a. (Generic a, GTextShowB (Rep a ())) => Int -> a -> Builder
genericShowbPrec Int
p = forall a. GTextShowB a => Int -> a -> Builder
gShowbPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Generic a => a -> Rep a ()
fromRepUnit

-- | A 'Generic' implementation of 'showbList'.
--
-- /Since: 2/
genericShowbList :: (Generic a, GTextShowB (Rep a ())) => [a] -> Builder
genericShowbList :: forall a. (Generic a, GTextShowB (Rep a ())) => [a] -> Builder
genericShowbList = forall a. (a -> Builder) -> [a] -> Builder
showbListWith forall a. (Generic a, GTextShowB (Rep a ())) => a -> Builder
genericShowb

-- | A 'Generic' implementation of 'printT'.
--
-- /Since: 2/
genericPrintT :: (Generic a, GTextShowT (Rep a ())) => a -> IO ()
genericPrintT :: forall a. (Generic a, GTextShowT (Rep a ())) => a -> IO ()
genericPrintT = Text -> IO ()
TS.putStrLn forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Generic a, GTextShowT (Rep a ())) => a -> Text
genericShowt

-- | A 'Generic' implementation of 'printTL'.
--
-- /Since: 2/
genericPrintTL :: (Generic a, GTextShowTL (Rep a ())) => a -> IO ()
genericPrintTL :: forall a. (Generic a, GTextShowTL (Rep a ())) => a -> IO ()
genericPrintTL = Text -> IO ()
TL.putStrLn forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Generic a, GTextShowTL (Rep a ())) => a -> Text
genericShowtl

-- | A 'Generic' implementation of 'hPrintT'.
--
-- /Since: 2/
genericHPrintT :: (Generic a, GTextShowT (Rep a ())) => Handle -> a -> IO ()
genericHPrintT :: forall a.
(Generic a, GTextShowT (Rep a ())) =>
Handle -> a -> IO ()
genericHPrintT Handle
h = Handle -> Text -> IO ()
TS.hPutStrLn Handle
h forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Generic a, GTextShowT (Rep a ())) => a -> Text
genericShowt

-- | A 'Generic' implementation of 'hPrintTL'.
--
-- /Since: 2/
genericHPrintTL :: (Generic a, GTextShowTL (Rep a ())) => Handle -> a -> IO ()
genericHPrintTL :: forall a.
(Generic a, GTextShowTL (Rep a ())) =>
Handle -> a -> IO ()
genericHPrintTL Handle
h = Handle -> Text -> IO ()
TL.hPutStrLn Handle
h forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Generic a, GTextShowTL (Rep a ())) => a -> Text
genericShowtl

-- | A 'Generic1' implementation of 'genericLiftShowbPrec'.
--
-- /Since: 2/
genericLiftShowbPrec :: (Generic1 f, GTextShowB1 (Rep1 f))
                     => (Int -> a -> Builder) -> ([a] -> Builder)
                     -> Int -> f a -> Builder
genericLiftShowbPrec :: forall (f :: * -> *) a.
(Generic1 f, GTextShowB1 (Rep1 f)) =>
(Int -> a -> Builder) -> ([a] -> Builder) -> Int -> f a -> Builder
genericLiftShowbPrec Int -> a -> Builder
sp [a] -> Builder
sl Int
p = forall (f :: * -> *) a.
GTextShowB1 f =>
(Int -> a -> Builder) -> ([a] -> Builder) -> Int -> f a -> Builder
gLiftShowbPrec Int -> a -> Builder
sp [a] -> Builder
sl Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1

-- | A 'Generic'/'Generic1' implementation of 'showbPrec1'.
--
-- /Since: 2/
genericShowbPrec1 :: ( Generic a, Generic1 f
                     , GTextShowB (Rep a ())
                     , GTextShowB1 (Rep1 f)
                     )
                  => Int -> f a -> Builder
genericShowbPrec1 :: forall a (f :: * -> *).
(Generic a, Generic1 f, GTextShowB (Rep a ()),
 GTextShowB1 (Rep1 f)) =>
Int -> f a -> Builder
genericShowbPrec1 = forall (f :: * -> *) a.
(Generic1 f, GTextShowB1 (Rep1 f)) =>
(Int -> a -> Builder) -> ([a] -> Builder) -> Int -> f a -> Builder
genericLiftShowbPrec forall a. (Generic a, GTextShowB (Rep a ())) => Int -> a -> Builder
genericShowbPrec forall a. (Generic a, GTextShowB (Rep a ())) => [a] -> Builder
genericShowbList

-- | A type-specialized version of 'from' used to assist type inference.
fromRepUnit :: Generic a => a -> Rep a ()
fromRepUnit :: forall a. Generic a => a -> Rep a ()
fromRepUnit = forall a x. Generic a => a -> Rep a x
from

-------------------------------------------------------------------------------

-- | Whether a constructor is a record ('Rec'), a tuple ('Tup'), is prefix ('Pref'),
-- or infix ('Inf').
--
-- /Since: 2/
data ConType = Rec | Tup | Pref | Inf String
  deriving ( Typeable ConType
ConType -> DataType
ConType -> Constr
(forall b. Data b => b -> b) -> ConType -> ConType
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ConType -> u
forall u. (forall d. Data d => d -> u) -> ConType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConType -> c ConType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConType)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConType -> m ConType
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConType -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ConType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ConType -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConType -> r
gmapT :: (forall b. Data b => b -> b) -> ConType -> ConType
$cgmapT :: (forall b. Data b => b -> b) -> ConType -> ConType
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConType)
dataTypeOf :: ConType -> DataType
$cdataTypeOf :: ConType -> DataType
toConstr :: ConType -> Constr
$ctoConstr :: ConType -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConType -> c ConType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConType -> c ConType
Data
           , ConType -> ConType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConType -> ConType -> Bool
$c/= :: ConType -> ConType -> Bool
== :: ConType -> ConType -> Bool
$c== :: ConType -> ConType -> Bool
Eq
           , forall x. Rep ConType x -> ConType
forall x. ConType -> Rep ConType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConType x -> ConType
$cfrom :: forall x. ConType -> Rep ConType x
Generic
           , Eq ConType
ConType -> ConType -> Bool
ConType -> ConType -> Ordering
ConType -> ConType -> ConType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ConType -> ConType -> ConType
$cmin :: ConType -> ConType -> ConType
max :: ConType -> ConType -> ConType
$cmax :: ConType -> ConType -> ConType
>= :: ConType -> ConType -> Bool
$c>= :: ConType -> ConType -> Bool
> :: ConType -> ConType -> Bool
$c> :: ConType -> ConType -> Bool
<= :: ConType -> ConType -> Bool
$c<= :: ConType -> ConType -> Bool
< :: ConType -> ConType -> Bool
$c< :: ConType -> ConType -> Bool
compare :: ConType -> ConType -> Ordering
$ccompare :: ConType -> ConType -> Ordering
Ord
           , ReadPrec [ConType]
ReadPrec ConType
Int -> ReadS ConType
ReadS [ConType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConType]
$creadListPrec :: ReadPrec [ConType]
readPrec :: ReadPrec ConType
$creadPrec :: ReadPrec ConType
readList :: ReadS [ConType]
$creadList :: ReadS [ConType]
readsPrec :: Int -> ReadS ConType
$creadsPrec :: Int -> ReadS ConType
Read
           , Int -> ConType -> ShowS
[ConType] -> ShowS
ConType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConType] -> ShowS
$cshowList :: [ConType] -> ShowS
show :: ConType -> String
$cshow :: ConType -> String
showsPrec :: Int -> ConType -> ShowS
$cshowsPrec :: Int -> ConType -> ShowS
Show
           , Typeable
#if __GLASGOW_HASKELL__ >= 800
           , forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => ConType -> m Exp
forall (m :: * -> *). Quote m => ConType -> Code m ConType
liftTyped :: forall (m :: * -> *). Quote m => ConType -> Code m ConType
$cliftTyped :: forall (m :: * -> *). Quote m => ConType -> Code m ConType
lift :: forall (m :: * -> *). Quote m => ConType -> m Exp
$clift :: forall (m :: * -> *). Quote m => ConType -> m Exp
Lift
#endif
           )

{-
I'm not particularly proud of the code below. The issue is that we need to be able to
generically work over Builders, strict Text, and lazy Text. We could just work
generically over Builders only and then convert to Text after the fact, but that results
in a drastic slowdown for certain datatypes (see GH-21 for an example).

For the most part, the shared functionality could be abstracted with a subclass of
Monoid that supports fromString, fromChar, etc. But there's a very small chance that
the code below is ever going to inline properly, and the runtime cost of all those
dictinary lookups is likely to be as bad as converting to Text at the end, if not worse.

Therefore, I perform some ugly CPP hackery to copy-paste the generic functionality three
times, once for each Text/Builder variant. At some point, I should replace this with TH.
See #33.
-}

hashPrec :: Int -> Int
#if __GLASGOW_HASKELL__ >= 711
hashPrec :: Int -> Int
hashPrec = forall a b. a -> b -> a
const Int
0
#else
hashPrec = id
#endif

#if __GLASGOW_HASKELL__ >= 711
#define HASH_FUNS(text_type,one_hash,two_hash,from_char,from_string) \
one_hash, two_hash :: text_type; \
one_hash  = from_char '#';       \
two_hash  = from_string "##";
#else
#define HASH_FUNS(text_type,one_hash,two_hash,from_char,from_string) \
one_hash, two_hash :: text_type; \
one_hash  = mempty;              \
two_hash  = mempty;
#endif

-- For some mysterious reason, attaching INLINE pragmas to things in this
-- module causes GHC 8.10's simplifier to absolutely explode in terms of
-- compile times. This also affects 9.0, 8.8, and older versions of GHC to
-- varying degrees, usually adding a couple of minutes or more to the overall
-- compile times.
--
-- We'd still like to include the INLINE pragmas on 9.2 or later, however, as
-- it delivers a modest but measurable performance boost in the benchmark suite.
-- As a compromise, we use CPP to only attach INLINE annotations on 9.2 or
-- later.
#if __GLASGOW_HASKELL__ >= 902
#define INLINE_GE_902(f) {-# INLINE f #-};
#else
#define INLINE_GE_902(f)
#endif

#if __GLASGOW_HASKELL__ >= 806
#define QUANTIFIED_SUPERCLASS(class_name,f) (forall a. TextShow a => class_name (f a)) =>
#else
#define QUANTIFIED_SUPERCLASS(class_name,f)
#endif

#define GTEXT_SHOW(text_type,show_funs,one_hash,two_hash,gtext_show,gtext_show1,gshow_prec,glift_show_prec,gtext_show_con,gtext_show_con1,gshow_prec_con,glift_show_prec_con,show_prec,lift_show_prec,show_space,show_paren,show_list,show_list_with,from_char,from_string,c1_show_prec,s1_show_prec,product_show_prec,u_char_show_prec,u_double_show_prec,u_float_show_prec,u_int_show_prec,u_word_show_prec) \
{- | Class of generic representation types that can be converted to a                   \
'text_type'.                                                                            \
                                                                                        \
/Since: 3.10/                                                                           \
-};                                                                                     \
class gtext_show a where {                                                              \
  ; gshow_prec :: Int -> a -> text_type                                                 \
};                                                                                      \
deriving instance Typeable gtext_show;                                                  \
                                                                                        \
instance gtext_show (f p) => gtext_show (D1 d f p) where {                              \
  ; gshow_prec p (M1 x) = gshow_prec p x                                                \
};                                                                                      \
                                                                                        \
instance gtext_show (V1 p) where {                                                      \
  ; gshow_prec _ x = case x of {}                                                       \
};                                                                                      \
                                                                                        \
instance (gtext_show (f p), gtext_show (g p))                                           \
      => gtext_show ((f :+: g) p) where {                                               \
  ; gshow_prec p (L1 x) = gshow_prec p x                                                \
  ; gshow_prec p (R1 x) = gshow_prec p x                                                \
};                                                                                      \
                                                                                        \
instance (Constructor c, gtext_show_con (f p), IsNullary f)                             \
    => gtext_show (C1 c f p) where {                                                    \
  gshow_prec = c1_show_prec gshow_prec_con                                              \
};                                                                                      \
                                                                                        \
{- | Class of generic representation types for which the 'ConType' has been             \
determined.                                                                             \
                                                                                        \
/Since: 3.10/                                                                           \
-};                                                                                     \
class gtext_show_con a where {                                                          \
  ; gshow_prec_con :: ConType -> Int -> a -> text_type                                  \
};                                                                                      \
deriving instance Typeable gtext_show_con;                                              \
                                                                                        \
instance gtext_show_con (U1 p) where {                                                  \
  ; gshow_prec_con _ _ U1 = mempty                                                      \
};                                                                                      \
                                                                                        \
instance TextShow p => gtext_show_con (Par1 p) where {                                  \
  ; gshow_prec_con _ p (Par1 x) = show_prec p x                                         \
};                                                                                      \
                                                                                        \
instance TextShow c => gtext_show_con (K1 i c p) where {                                \
  ; gshow_prec_con _ p (K1 x) = show_prec p x                                           \
};                                                                                      \
                                                                                        \
instance (TextShow1 f, TextShow p) => gtext_show_con (Rec1 f p) where {                 \
  ; gshow_prec_con _ p (Rec1 x) = lift_show_prec show_prec show_list p x                \
};                                                                                      \
                                                                                        \
instance (Selector s, gtext_show_con (f p)) => gtext_show_con (S1 s f p) where {        \
  ; gshow_prec_con t = s1_show_prec $ gshow_prec_con t                                  \
};                                                                                      \
                                                                                        \
instance (gtext_show_con (f p), gtext_show_con (g p))                                   \
      => gtext_show_con ((f :*: g) p) where {                                           \
  ; gshow_prec_con t = product_show_prec (gshow_prec_con t) (gshow_prec_con t) t        \
};                                                                                      \
                                                                                        \
instance (TextShow1 f, gtext_show_con (g p)) => gtext_show_con ((f :.: g) p) where {    \
  ; gshow_prec_con t p (Comp1 x) =                                                      \
      let gspc = gshow_prec_con t                                                       \
      in lift_show_prec gspc (show_list_with (gspc 0)) p x                              \
};                                                                                      \
                                                                                        \
instance gtext_show_con (UChar p) where {                                               \
  ; gshow_prec_con _ = u_char_show_prec show_prec                                       \
};                                                                                      \
                                                                                        \
instance gtext_show_con (UDouble p) where {                                             \
  ; gshow_prec_con _ = u_double_show_prec show_prec                                     \
};                                                                                      \
                                                                                        \
instance gtext_show_con (UFloat p) where {                                              \
  ; gshow_prec_con _ = u_float_show_prec show_prec                                      \
};                                                                                      \
                                                                                        \
instance gtext_show_con (UInt p) where {                                                \
  ; gshow_prec_con _ = u_int_show_prec show_prec                                        \
};                                                                                      \
                                                                                        \
instance gtext_show_con (UWord p) where {                                               \
  ; gshow_prec_con _ = u_word_show_prec show_prec                                       \
};                                                                                      \
                                                                                        \
{- | Class of generic representation types for unary type constructors that can         \
be converted to a 'text_type'.                                                          \
                                                                                        \
/Since: 3.10/                                                                           \
-};                                                                                     \
class QUANTIFIED_SUPERCLASS(gtext_show,f)                                               \
      gtext_show1 f where {                                                             \
  ; glift_show_prec :: (Int -> a -> text_type) -> ([a] -> text_type)                    \
                    -> Int -> f a -> text_type                                          \
};                                                                                      \
deriving instance Typeable gtext_show1;                                                 \
                                                                                        \
instance gtext_show1 f => gtext_show1 (D1 d f) where {                                  \
  ; glift_show_prec sp sl p (M1 x) = glift_show_prec sp sl p x                          \
};                                                                                      \
                                                                                        \
instance gtext_show1 V1 where {                                                         \
  ; glift_show_prec _ _ _ x = case x of {}                                              \
};                                                                                      \
                                                                                        \
instance (gtext_show1 f, gtext_show1 g) => gtext_show1 (f :+: g) where {                \
  ; glift_show_prec sp sl p (L1 x) = glift_show_prec sp sl p x                          \
  ; glift_show_prec sp sl p (R1 x) = glift_show_prec sp sl p x                          \
};                                                                                      \
                                                                                        \
instance (Constructor c, gtext_show_con1 f, IsNullary f)                                \
    => gtext_show1 (C1 c f) where {                                                     \
  ; glift_show_prec sp sl = c1_show_prec $ glift_show_prec_con sp sl                    \
};                                                                                      \
                                                                                        \
{- | Class of generic representation types for unary type constructors for which        \
the 'ConType' has been determined.                                                      \
                                                                                        \
/Since: 3.10/                                                                           \
-};                                                                                     \
class QUANTIFIED_SUPERCLASS(gtext_show_con,f)                                           \
      gtext_show_con1 f where {                                                         \
  ; glift_show_prec_con :: (Int -> a -> text_type) -> ([a] -> text_type)                \
                        -> ConType -> Int -> f a -> text_type                           \
};                                                                                      \
deriving instance Typeable gtext_show_con1;                                             \
                                                                                        \
instance gtext_show_con1 U1 where {                                                     \
  ; glift_show_prec_con _ _ _ _ U1 = mempty                                             \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 Par1 where {                                                   \
  ; glift_show_prec_con sp _ _ p (Par1 x) = sp p x                                      \
};                                                                                      \
                                                                                        \
instance TextShow c => gtext_show_con1 (K1 i c) where {                                 \
  ; glift_show_prec_con _ _ _ p (K1 x) = show_prec p x                                  \
};                                                                                      \
                                                                                        \
instance TextShow1 f => gtext_show_con1 (Rec1 f) where {                                \
  ; glift_show_prec_con sp sl _ p (Rec1 x) = lift_show_prec sp sl p x                   \
};                                                                                      \
                                                                                        \
instance (Selector s, gtext_show_con1 f) => gtext_show_con1 (S1 s f) where {            \
  ; glift_show_prec_con sp sl t = s1_show_prec $ glift_show_prec_con sp sl t            \
};                                                                                      \
                                                                                        \
instance (gtext_show_con1 f, gtext_show_con1 g)                                         \
      => gtext_show_con1 (f :*: g) where {                                              \
  ; glift_show_prec_con sp sl t =                                                       \
      product_show_prec (glift_show_prec_con sp sl t) (glift_show_prec_con sp sl t) t   \
};                                                                                      \
                                                                                        \
instance (TextShow1 f, gtext_show_con1 g) => gtext_show_con1 (f :.: g) where {          \
  ; glift_show_prec_con sp sl t p (Comp1 x) =                                           \
      let gspc = glift_show_prec_con sp sl t                                            \
      in lift_show_prec gspc (show_list_with (gspc 0)) p x                              \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 UChar where {                                                  \
  ; glift_show_prec_con _ _ _ = u_char_show_prec show_prec                              \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 UDouble where {                                                \
  ; glift_show_prec_con _ _ _ = u_double_show_prec show_prec                            \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 UFloat where {                                                 \
  ; glift_show_prec_con _ _ _ = u_float_show_prec show_prec                             \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 UInt where {                                                   \
  ; glift_show_prec_con _ _ _ = u_int_show_prec show_prec                               \
};                                                                                      \
                                                                                        \
instance gtext_show_con1 UWord where {                                                  \
  ; glift_show_prec_con _ _ _ = u_word_show_prec show_prec                              \
};                                                                                      \
                                                                                        \
c1_show_prec :: forall c f p.                                                           \
                (Constructor c, IsNullary f)                                            \
             => (ConType -> Int -> f p -> text_type)                                    \
             -> Int -> C1 c f p -> text_type;                                           \
c1_show_prec sp p c@(M1 x) = case fixity of {                                           \
  ; Prefix -> show_paren ( p > appPrec                                                  \
                           && not (isNullary x || conIsTuple c)                         \
                         ) $                                                            \
           (if conIsTuple c                                                             \
               then mempty                                                              \
               else let cn = conName c                                                  \
                    in show_paren (isInfixDataCon cn) $ from_string cn)                 \
        <> (if isNullary x || conIsTuple c                                              \
               then mempty                                                              \
               else from_char ' ')                                                      \
        <> showBraces t (sp t appPrec1 x)                                               \
  ; Infix _ m -> show_paren (p > m) $ sp t (m+1) x                                      \
} where {                                                                               \
    ; fixity :: Fixity                                                                  \
    ; fixity = conFixity c                                                              \
                                                                                        \
    ; t :: ConType                                                                      \
    ; t = if conIsRecord c                                                              \
          then Rec                                                                      \
          else case conIsTuple c of {                                                   \
                 ; True  -> Tup                                                         \
                 ; False -> case fixity of {                                            \
                     ; Prefix    -> Pref                                                \
                     ; Infix _ _ -> Inf $ conName c                                     \
                     };                                                                 \
                 };                                                                     \
                                                                                        \
    ; showBraces :: ConType -> text_type -> text_type                                   \
    ; showBraces Rec     b = from_char '{' <> b <> from_char '}'                        \
    ; showBraces Tup     b = from_char '(' <> b <> from_char ')'                        \
    ; showBraces Pref    b = b                                                          \
    ; showBraces (Inf _) b = b                                                          \
                                                                                        \
    ; conIsTuple :: C1 c f p -> Bool                                                    \
    ; conIsTuple = isTupleString . conName                                              \
  };                                                                                    \
INLINE_GE_902(c1_show_prec)                                                            \
                                                                                        \
s1_show_prec :: Selector s                                                              \
             => (Int -> f p -> text_type)                                               \
             -> Int -> S1 s f p -> text_type;                                           \
s1_show_prec sp p sel@(M1 x)                                                            \
  | selName sel == "" = sp p x                                                          \
  | otherwise         = infixRec                                                        \
                        <> " = "                                                        \
                        <> sp 0 x                                                       \
  where {                                                                               \
    ; infixRec :: text_type                                                             \
    ; infixRec | isSymVar selectorName                                                  \
               = from_char '(' <> from_string selectorName <> from_char ')'             \
               | otherwise                                                              \
               = from_string selectorName                                               \
                                                                                        \
    ; selectorName :: String                                                            \
    ; selectorName = selName sel                                                        \
  };                                                                                    \
INLINE_GE_902(s1_show_prec)                                                            \
                                                                                        \
product_show_prec :: (Int -> f p -> text_type) -> (Int -> g p -> text_type)             \
                  -> ConType -> Int -> (f :*: g) p -> text_type;                        \
product_show_prec spf spg t p (a :*: b) =                                               \
  case t of {                                                                           \
    ; Rec ->                                                                            \
           spf 0 a                                                                      \
        <> ", "                                                                         \
        <> spg 0 b                                                                      \
    ; Inf o ->                                                                          \
           spf p a                                                                      \
        <> show_space                                                                   \
        <> infixOp o                                                                    \
        <> show_space                                                                   \
        <> spg p b                                                                      \
    ; Tup ->                                                                            \
           spf 0 a                                                                      \
        <> from_char ','                                                                \
        <> spg 0 b                                                                      \
    ; Pref ->                                                                           \
           spf p a                                                                      \
        <> show_space                                                                   \
        <> spg p b                                                                      \
  } where {                                                                             \
      ; infixOp :: String -> text_type                                                  \
      ; infixOp o = if isInfixDataCon o                                                 \
                       then from_string o                                               \
                       else from_char '`' <> from_string o <> from_char '`'             \
  };                                                                                    \
INLINE_GE_902(product_show_prec)                                                       \
                                                                                        \
u_char_show_prec :: (Int -> Char -> text_type) -> Int -> UChar p -> text_type;          \
u_char_show_prec sp p (UChar c) = sp (hashPrec p) (C# c) <> one_hash;                   \
INLINE_GE_902(u_char_show_prec)                                                        \
                                                                                        \
u_double_show_prec :: (Int -> Double -> text_type) -> Int -> UDouble p -> text_type;    \
u_double_show_prec sp p (UDouble d) = sp (hashPrec p) (D# d) <> two_hash;               \
INLINE_GE_902(u_double_show_prec)                                                      \
                                                                                        \
u_float_show_prec :: (Int -> Float -> text_type) -> Int -> UFloat p -> text_type;       \
u_float_show_prec sp p (UFloat f) = sp (hashPrec p) (F# f) <> one_hash;                 \
INLINE_GE_902(u_float_show_prec)                                                       \
                                                                                        \
u_int_show_prec :: (Int -> Int -> text_type) -> Int -> UInt p -> text_type;             \
u_int_show_prec sp p (UInt i) = sp (hashPrec p) (I# i) <> one_hash;                     \
INLINE_GE_902(u_int_show_prec)                                                         \
                                                                                        \
u_word_show_prec :: (Int -> Word -> text_type) -> Int -> UWord p -> text_type;          \
u_word_show_prec sp p (UWord w) = sp (hashPrec p) (W# w) <> two_hash;                   \
INLINE_GE_902(u_word_show_prec)                                                        \
                                                                                        \
HASH_FUNS(text_type,one_hash,two_hash,from_char,from_string);

GTEXT_SHOW(Builder,ShowFunsB,oneHashB,twoHashB,GTextShowB,GTextShowB1,gShowbPrec,gLiftShowbPrec,GTextShowConB,GTextShowConB1,gShowbPrecCon,gLiftShowbPrecCon,showbPrec,liftShowbPrec,showbSpace,showbParen,showbList,showbListWith,TB.singleton,TB.fromString,c1ShowbPrec,s1ShowbPrec,productShowbPrec,uCharShowbPrec,uDoubleShowbPrec,uFloatShowbPrec,uIntShowbPrec,uWordShowbPrec)
GTEXT_SHOW(TS.Text,ShowFunsT,oneHashT,twoHashT,GTextShowT,GTextShowT1,gShowtPrec,gLiftShowtPrec,GTextShowConT,GTextShowConT1,gShowtPrecCon,gLiftShowtPrecCon,showtPrec,liftShowtPrec,showtSpace,showtParen,showtList,showtListWith,TS.singleton,TS.pack,c1ShowtPrec,s1ShowtPrec,productShowtPrec,uCharShowtPrec,uDoubleShowtPrec,uFloatShowtPrec,uIntShowtPrec,uWordShowtPrec)
GTEXT_SHOW(TL.Text,ShowFunsTL,oneHashTL,twoHashTL,GTextShowTL,GTextShowTL1,gShowtlPrec,gLiftShowtlPrec,GTextShowConTL,GTextShowConTL1,gShowtlPrecCon,gLiftShowtlPrecCon,showtlPrec,liftShowtlPrec,showtlSpace,showtlParen,showtlList,showtlListWith,TL.singleton,TL.pack,c1ShowtlPrec,s1ShowtlPrec,productShowtlPrec,uCharShowtlPrec,uDoubleShowtlPrec,uFloatShowtlPrec,uIntShowtlPrec,uWordShowtlPrec)

-- | Class of generic representation types that represent a constructor with
-- zero or more fields.
class IsNullary f where
    -- Returns 'True' if the constructor has no fields.
    isNullary :: f a -> Bool

instance IsNullary U1 where
    isNullary :: forall (a :: k). U1 a -> Bool
isNullary U1 a
_ = Bool
True

instance IsNullary Par1 where
    isNullary :: forall a. Par1 a -> Bool
isNullary Par1 a
_ = Bool
False

instance IsNullary (K1 i c) where
    isNullary :: forall (a :: k). K1 i c a -> Bool
isNullary K1 i c a
_ = Bool
False

instance IsNullary f => IsNullary (S1 s f) where
    isNullary :: forall (a :: k). S1 s f a -> Bool
isNullary (M1 f a
x) = forall {k} (f :: k -> *) (a :: k). IsNullary f => f a -> Bool
isNullary f a
x

instance IsNullary (Rec1 f) where
    isNullary :: forall (a :: k). Rec1 f a -> Bool
isNullary Rec1 f a
_ = Bool
False

instance IsNullary (f :*: g) where
    isNullary :: forall (a :: k). (:*:) f g a -> Bool
isNullary (:*:) f g a
_ = Bool
False

instance IsNullary (f :.: g) where
    isNullary :: forall (a :: k). (:.:) f g a -> Bool
isNullary (:.:) f g a
_ = Bool
False

instance IsNullary UChar where
    isNullary :: forall (a :: k). UChar a -> Bool
isNullary UChar a
_ = Bool
False

instance IsNullary UDouble where
    isNullary :: forall (a :: k). UDouble a -> Bool
isNullary UDouble a
_ = Bool
False

instance IsNullary UFloat where
    isNullary :: forall (a :: k). UFloat a -> Bool
isNullary UFloat a
_ = Bool
False

instance IsNullary UInt where
    isNullary :: forall (a :: k). UInt a -> Bool
isNullary UInt a
_ = Bool
False

instance IsNullary UWord where
    isNullary :: forall (a :: k). UWord a -> Bool
isNullary UWord a
_ = Bool
False

-------------------------------------------------------------------------------

$(deriveTextShow ''ConType)

#if __GLASGOW_HASKELL__ < 800
$(deriveLift ''ConType)
$(deriveLift ''FromGeneric)

instance Lift (f a) => Lift (FromGeneric1 f a) where
    lift = $(makeLift ''FromGeneric1)
#endif

#if !defined(__LANGUAGE_DERIVE_GENERIC1__)
$(Generics.deriveMeta           ''FromGeneric1)
$(Generics.deriveRepresentable1 ''FromGeneric1)
#endif