text-show-instances 2.1 → 3
raw patch · 39 files changed
+884/−868 lines, 39 filesdep +generic-derivingdep ~bifunctorsdep ~binarydep ~semigroups
Dependencies added: generic-deriving
Dependency ranges changed: bifunctors, binary, semigroups, text-show, text-show-instances, time, transformers-compat
Files
- CHANGELOG.md +9/−0
- src/TextShow/Compiler/Hoopl.hs +24/−24
- src/TextShow/Control/Applicative/Trans.hs +21/−21
- src/TextShow/Control/Monad/Trans.hs +80/−81
- src/TextShow/Data/Bifunctor.hs +120/−58
- src/TextShow/Data/Binary.hs +9/−9
- src/TextShow/Data/Containers.hs +58/−92
- src/TextShow/Data/Functor/Trans.hs +30/−88
- src/TextShow/Data/List/NonEmpty.hs +0/−31
- src/TextShow/Data/Semigroup.hs +0/−105
- src/TextShow/Data/Tagged.hs +10/−10
- src/TextShow/Data/Time.hs +2/−4
- src/TextShow/Data/UnorderedContainers.hs +21/−29
- src/TextShow/Data/Vector.hs +16/−25
- src/TextShow/Instances.hs +0/−2
- src/TextShow/Language/Haskell/TH.hs +97/−11
- src/TextShow/System/Console/Haskeline.hs +1/−1
- src/TextShow/System/Console/Terminfo.hs +1/−1
- src/TextShow/System/Directory.hs +1/−1
- src/TextShow/System/Locale.hs +1/−1
- src/TextShow/System/Posix.hs +1/−1
- src/TextShow/System/Random.hs +1/−1
- src/TextShow/System/Time.hs +1/−1
- src/TextShow/System/Win32.hs +1/−1
- src/TextShow/Text/PrettyPrint.hs +87/−6
- src/TextShow/Trace/Hpc.hs +1/−1
- src/TextShow/Utils.hs +4/−34
- tests/Instances/Data/Bifunctor.hs +2/−0
- tests/Instances/Data/List/NonEmpty.hs +0/−22
- tests/Instances/Data/Semigroup.hs +0/−32
- tests/Instances/Language/Haskell/TH.hs +119/−19
- tests/Instances/Text/PrettyPrint.hs +27/−5
- tests/Spec/Data/BifunctorSpec.hs +3/−0
- tests/Spec/Data/List/NonEmptySpec.hs +0/−31
- tests/Spec/Data/SemigroupSpec.hs +0/−56
- tests/Spec/Language/Haskell/THSpec.hs +33/−0
- tests/Spec/Text/PrettyPrintSpec.hs +24/−9
- tests/Spec/Utils.hs +46/−32
- text-show-instances.cabal +33/−23
CHANGELOG.md view
@@ -1,3 +1,12 @@+## 3+* GHC 8.0 support+* Rename functions that previously ended with the suffix `-With` to instead have the prefix `lift-`, consistent with `text-show-3`+* Removed the `TextShow.Data.Semigroup` and `TextShow.Data.List.NonEmpty` modules, as they have been moved to `text-show-3` (as part of moving `Semigroup` into `base`)+* Removed the functions for `Compose`, `Product`, and `Sum` in `TextShow.Data.Functor.Trans`, as they have been moved to `text-show-3` (as part of moving them to `base`)+* Add `TextShow`/`TextShow1` instances for `Fix` and `Sum` in `TextShow.Data.Bifunctor`+* Add `TextShow`/`TextShow1` instances for the datatypes in `Text.PrettyPrint.Annotated` (introduced in @pretty-1.1.1.3@)+* Add `TextShow` instances for the new datatypes in @template-haskell-2.11.0.0@+ ## 2.1 * Reexport the `TextShow` classes and module from `TextShow.Instances`. This helps Haddock readers discover what new instances are added with `text-show-instances`. * Make `Tagged` instances poly-kinded
src/TextShow/Compiler/Hoopl.hs view
@@ -17,11 +17,11 @@ -} module TextShow.Compiler.Hoopl ( showbLabel- , showbLabelMapPrecWith+ , liftShowbLabelMapPrec , showbLabelSetPrec- , showbPointedWith+ , liftShowbPointed , showbUnique- , showbUniqueMapPrecWith+ , liftShowbUniqueMapPrec , showbUniqueSetPrec , showbDominatorNode , showbDominatorTree@@ -39,8 +39,8 @@ import Data.Monoid.Compat -import TextShow (TextShow(showb, showbPrec), TextShow1(..),- TextShow2(..), Builder, singleton)+import TextShow (TextShow(..), TextShow1(..),+ TextShow2(..), Builder, singleton, showbPrec1) import TextShow.Data.Containers () import TextShow.Data.Integral (showbIntPrec) import TextShow.TH (deriveTextShow, deriveTextShow1)@@ -56,10 +56,10 @@ -- | Convert a 'LabelMap' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbLabelMapPrecWith :: (Int -> v -> Builder) -> Int -> LabelMap v -> Builder-showbLabelMapPrecWith = showbPrecWith-{-# INLINE showbLabelMapPrecWith #-}+-- /Since: 3/+liftShowbLabelMapPrec :: (v -> Builder) -> Int -> LabelMap v -> Builder+liftShowbLabelMapPrec sp = liftShowbPrec (const sp) undefined+{-# INLINE liftShowbLabelMapPrec #-} -- | Convert a 'LabelSet' to a 'Builder' with the given precedence. --@@ -70,12 +70,12 @@ -- | Convert a 'Pointed' value to a 'Builder' with the given show function. ----- /Since: 2/-showbPointedWith :: (a -> Builder) -> Pointed t b a -> Builder-showbPointedWith _ Bot = "_|_"-showbPointedWith _ Top = singleton 'T'-showbPointedWith sp (PElem a) = sp a-{-# INLINE showbPointedWith #-}+-- /Since: 3/+liftShowbPointed :: (a -> Builder) -> Pointed t b a -> Builder+liftShowbPointed _ Bot = "_|_"+liftShowbPointed _ Top = singleton 'T'+liftShowbPointed sp (PElem a) = sp a+{-# INLINE liftShowbPointed #-} -- | Convert a 'Unique' value to a 'Builder'. --@@ -90,10 +90,10 @@ -- | Convert a 'UniqueMap' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbUniqueMapPrecWith :: (Int -> v -> Builder) -> Int -> UniqueMap v -> Builder-showbUniqueMapPrecWith = showbPrecWith-{-# INLINE showbUniqueMapPrecWith #-}+-- /Since: 3/+liftShowbUniqueMapPrec :: (v -> Builder) -> Int -> UniqueMap v -> Builder+liftShowbUniqueMapPrec sp = liftShowbPrec (const sp) undefined+{-# INLINE liftShowbUniqueMapPrec #-} -- | Convert a 'UniqueSet' to a 'Builder' with the given precedence. --@@ -156,16 +156,16 @@ $(deriveTextShow ''LabelSet) instance TextShow a => TextShow (Pointed t b a) where- showbPrec = showbPrecWith showbPrec+ showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 (Pointed t b) where- showbPrecWith sp _ = showbPointedWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec sp _ _ = liftShowbPointed $ sp 0+ INLINE_INST_FUN(liftShowbPrec) instance TextShow2 (Pointed t) where- showbPrecWith2 _ = showbPrecWith- INLINE_INST_FUN(showbPrecWith2)+ liftShowbPrec2 _ _ = liftShowbPrec+ INLINE_INST_FUN(liftShowbPrec2) #if !(MIN_VERSION_hoopl(3,9,0)) instance TextShow Unique where
src/TextShow/Control/Applicative/Trans.hs view
@@ -14,51 +14,51 @@ /Since: 2/ -} module TextShow.Control.Applicative.Trans (- showbBackwardsPrecWith- , showbLiftPrecWith+ liftShowbBackwardsPrec+ , liftShowbLiftPrec ) where import Control.Applicative.Backwards (Backwards(..)) import Control.Applicative.Lift (Lift(..)) -import TextShow (TextShow(showbPrec), TextShow1(..),+import TextShow (TextShow(..), TextShow1(..), Builder, showbPrec1, showbUnaryWith) #include "inline.h" --- | Convert a 'Backwards' value to a 'Builder' with the given show function+-- | Convert a 'Backwards' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbBackwardsPrecWith :: TextShow1 f- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbBackwardsPrec :: TextShow1 f+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> Backwards f a -> Builder-showbBackwardsPrecWith sp p (Backwards x)- = showbUnaryWith (showbPrecWith sp) "Backwards" p x-{-# INLINE showbBackwardsPrecWith #-}+liftShowbBackwardsPrec sp sl p (Backwards x)+ = showbUnaryWith (liftShowbPrec sp sl) "Backwards" p x+{-# INLINE liftShowbBackwardsPrec #-} --- | Convert a 'Lift' value to a 'Builder' with the given show function and precedence.+-- | Convert a 'Lift' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbLiftPrecWith :: TextShow1 f- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbLiftPrec :: TextShow1 f+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> Lift f a -> Builder-showbLiftPrecWith sp p (Pure x) = showbUnaryWith sp "Pure" p x-showbLiftPrecWith sp p (Other y) = showbUnaryWith (showbPrecWith sp) "Other" p y-{-# INLINE showbLiftPrecWith #-}+liftShowbLiftPrec sp _ p (Pure x) = showbUnaryWith sp "Pure" p x+liftShowbLiftPrec sp sl p (Other y) = showbUnaryWith (liftShowbPrec sp sl) "Other" p y+{-# INLINE liftShowbLiftPrec #-} instance (TextShow1 f, TextShow a) => TextShow (Backwards f a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 f => TextShow1 (Backwards f) where- showbPrecWith = showbBackwardsPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbBackwardsPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow1 f, TextShow a) => TextShow (Lift f a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 f => TextShow1 (Lift f) where- showbPrecWith = showbLiftPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbLiftPrec+ INLINE_INST_FUN(liftShowbPrec)
src/TextShow/Control/Monad/Trans.hs view
@@ -14,14 +14,13 @@ /Since: 2/ -} module TextShow.Control.Monad.Trans (- showbErrorTPrecWith- , showbExceptTPrecWith- , showbIdentityTPrecWith- , showbListTPrec- , showbListTPrecWith- , showbMaybeTPrecWith- , showbWriterTLazyPrecWith- , showbWriterTStrictPrecWith+ liftShowbErrorTPrec+ , liftShowbExceptTPrec+ , liftShowbIdentityTPrec+ , liftShowbListTPrec+ , liftShowbMaybeTPrec+ , liftShowbWriterTLazyPrec+ , liftShowbWriterTStrictPrec ) where import Control.Monad.Trans.Error (ErrorT(..))@@ -32,147 +31,147 @@ import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT(..)) import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT(..)) -import TextShow (TextShow(showb, showbPrec), TextShow1(..),+import TextShow (TextShow(..), TextShow1(..), TextShow2(..), Builder, showbPrec1, showbUnaryWith)-import TextShow.Data.Tuple (showb2TupleWith2) #include "inline.h" --- | Convert an 'ErrorT' value to a 'Builder' with the given show function+-- | Convert an 'ErrorT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbErrorTPrecWith :: (TextShow e, TextShow1 m)- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbErrorTPrec :: (TextShow e, TextShow1 m)+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> ErrorT e m a -> Builder-showbErrorTPrecWith sp p (ErrorT m) =- showbUnaryWith (showbPrecWith (showbPrecWith sp)) "ErrorT" p m-{-# INLINE showbErrorTPrecWith #-}+liftShowbErrorTPrec sp sl p (ErrorT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec sp sl)+ (liftShowbList sp sl)) "ErrorT" p m+{-# INLINE liftShowbErrorTPrec #-} --- | Convert an 'ExceptT' value to a 'Builder' with the given show function+-- | Convert an 'ExceptT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbExceptTPrecWith :: (TextShow e, TextShow1 m)- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbExceptTPrec :: (TextShow e, TextShow1 m)+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> ExceptT e m a -> Builder-showbExceptTPrecWith sp p (ExceptT m) =- showbUnaryWith (showbPrecWith (showbPrecWith sp)) "ExceptT" p m-{-# INLINE showbExceptTPrecWith #-}+liftShowbExceptTPrec sp sl p (ExceptT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec sp sl)+ (liftShowbList sp sl)) "ExceptT" p m+{-# INLINE liftShowbExceptTPrec #-} --- | Convert an 'IdentityT' value to a 'Builder' with the given show function+-- | Convert an 'IdentityT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbIdentityTPrecWith :: TextShow1 f- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbIdentityTPrec :: TextShow1 f+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> IdentityT f a -> Builder-showbIdentityTPrecWith sp p (IdentityT m) =- showbUnaryWith (showbPrecWith sp) "IdentityT" p m-{-# INLINE showbIdentityTPrecWith #-}---- | Convert a 'ListT' value to a 'Builder' with the given precedence.------ /Since: 2/-showbListTPrec :: (TextShow1 m, TextShow a) => Int -> ListT m a -> Builder-showbListTPrec p (ListT m) = showbUnaryWith (showbPrecWith showbPrec) "ListT" p m-{-# INLINE showbListTPrec #-}+liftShowbIdentityTPrec sp sl p (IdentityT m) =+ showbUnaryWith (liftShowbPrec sp sl) "IdentityT" p m+{-# INLINE liftShowbIdentityTPrec #-} --- | Convert a 'ListT' value to a 'Builder' with the given show function and precedence.+-- | Convert a 'ListT' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbListTPrecWith :: TextShow1 m- => (a -> Builder)+-- /Since: 3/+liftShowbListTPrec :: TextShow1 m+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> ListT m a -> Builder-showbListTPrecWith sp p (ListT m) =- showbUnaryWith (showbPrecWith (showbPrecWith (const sp))) "ListT" p m-{-# INLINE showbListTPrecWith #-}+liftShowbListTPrec sp sl p (ListT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec sp sl)+ (liftShowbList sp sl)) "ListT" p m+{-# INLINE liftShowbListTPrec #-} --- | Convert a 'MaybeT' value to a 'Builder' with the given show function+-- | Convert a 'MaybeT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbMaybeTPrecWith :: TextShow1 m- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbMaybeTPrec :: TextShow1 m+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> MaybeT m a -> Builder-showbMaybeTPrecWith sp p (MaybeT m) =- showbUnaryWith (showbPrecWith (showbPrecWith sp)) "MaybeT" p m-{-# INLINE showbMaybeTPrecWith #-}+liftShowbMaybeTPrec sp sl p (MaybeT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec sp sl)+ (liftShowbList sp sl)) "MaybeT" p m+{-# INLINE liftShowbMaybeTPrec #-} --- | Convert a lazy 'WL.WriterT' value to a 'Builder' with the given show function+-- | Convert a lazy 'WL.WriterT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbWriterTLazyPrecWith :: (TextShow w, TextShow1 m)- => (a -> Builder)+-- /Since: 3/+liftShowbWriterTLazyPrec :: (TextShow w, TextShow1 m)+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> WL.WriterT w m a -> Builder-showbWriterTLazyPrecWith sp p (WL.WriterT m) =- showbUnaryWith (showbPrecWith (const $ showb2TupleWith2 sp showb)) "WriterT" p m-{-# INLINE showbWriterTLazyPrecWith #-}+liftShowbWriterTLazyPrec sp sl p (WL.WriterT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec2 sp sl showbPrec showbList)+ (liftShowbList2 sp sl showbPrec showbList))+ "WriterT" p m+{-# INLINE liftShowbWriterTLazyPrec #-} --- | Convert a strict 'WS.WriterT' value to a 'Builder' with the given show function+-- | Convert a strict 'WS.WriterT' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbWriterTStrictPrecWith :: (TextShow w, TextShow1 m)- => (a -> Builder)+-- /Since: 3/+liftShowbWriterTStrictPrec :: (TextShow w, TextShow1 m)+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> WS.WriterT w m a -> Builder-showbWriterTStrictPrecWith sp p (WS.WriterT m) =- showbUnaryWith (showbPrecWith (const $ showb2TupleWith2 sp showb)) "WriterT" p m-{-# INLINE showbWriterTStrictPrecWith #-}+liftShowbWriterTStrictPrec sp sl p (WS.WriterT m) =+ showbUnaryWith (liftShowbPrec (liftShowbPrec2 sp sl showbPrec showbList)+ (liftShowbList2 sp sl showbPrec showbList))+ "WriterT" p m+{-# INLINE liftShowbWriterTStrictPrec #-} instance (TextShow e, TextShow1 m, TextShow a) => TextShow (ErrorT e m a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance (TextShow e, TextShow1 m) => TextShow1 (ErrorT e m) where- showbPrecWith = showbErrorTPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbErrorTPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow e, TextShow1 m, TextShow a) => TextShow (ExceptT e m a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance (TextShow e, TextShow1 m) => TextShow1 (ExceptT e m) where- showbPrecWith = showbExceptTPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbExceptTPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow1 f, TextShow a) => TextShow (IdentityT f a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 f => TextShow1 (IdentityT f) where- showbPrecWith = showbIdentityTPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbIdentityTPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow1 m, TextShow a) => TextShow (ListT m a) where- showbPrec = showbListTPrec+ showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 m => TextShow1 (ListT m) where- showbPrecWith sp = showbListTPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbListTPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow1 m, TextShow a) => TextShow (MaybeT m a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 m => TextShow1 (MaybeT m) where- showbPrecWith = showbMaybeTPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbMaybeTPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow w, TextShow1 m, TextShow a) => TextShow (WL.WriterT w m a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance (TextShow w, TextShow1 m) => TextShow1 (WL.WriterT w m) where- showbPrecWith sp = showbWriterTLazyPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbWriterTLazyPrec+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow w, TextShow1 m, TextShow a) => TextShow (WS.WriterT w m a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance (TextShow w, TextShow1 m) => TextShow1 (WS.WriterT w m) where- showbPrecWith sp = showbWriterTStrictPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbWriterTStrictPrec+ INLINE_INST_FUN(liftShowbPrec)
src/TextShow/Data/Bifunctor.hs view
@@ -17,34 +17,40 @@ -} module TextShow.Data.Bifunctor ( showbBiffPrec- , showbBiffPrecWith2+ , liftShowbBiffPrec2 , showbClownPrec- , showbClownPrecWith+ , liftShowbClownPrec+ , showbFixPrec+ , liftShowbFixPrec , showbFlipPrec- , showbFlipPrecWith2+ , liftShowbFlipPrec2 , showbJoinPrec- , showbJoinPrecWith+ , liftShowbJoinPrec , showbJokerPrec- , showbJokerPrecWith+ , liftShowbJokerPrec , showbProductPrec- , showbProductPrecWith2+ , liftShowbProductPrec2+ , showbSumPrec+ , liftShowbSumPrec2 , showbTannenPrec- , showbTannenPrecWith2+ , liftShowbTannenPrec2 , showbWrappedBifunctorPrec- , showbWrappedBifunctorPrecWith2+ , liftShowbWrappedBifunctorPrec2 ) where import Data.Bifunctor.Biff (Biff) import Data.Bifunctor.Clown (Clown)+import Data.Bifunctor.Fix (Fix(..)) import Data.Bifunctor.Flip (Flip) import Data.Bifunctor.Join (Join(..)) import Data.Bifunctor.Joker (Joker) import Data.Bifunctor.Product (Product)+import Data.Bifunctor.Sum (Sum) import Data.Bifunctor.Tannen (Tannen) import Data.Bifunctor.Wrapped (WrappedBifunctor) import TextShow (TextShow(..), TextShow1(..), TextShow2(..), Builder)-import TextShow.TH (deriveTextShow1, deriveTextShow2, makeShowbPrec, makeShowbPrecWith)+import TextShow.TH (deriveTextShow2, makeShowbPrec, makeLiftShowbPrec) -- | Convert a 'Biff' value to a 'Builder' with the given precedence. --@@ -55,12 +61,13 @@ -- | Convert a 'Biff' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbBiffPrecWith2 :: (TextShow2 p, TextShow1 f, TextShow1 g)- => (Int -> a -> Builder) -> (Int -> b -> Builder)+-- /Since: 3/+liftShowbBiffPrec2 :: (TextShow2 p, TextShow1 f, TextShow1 g)+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder) -> Int -> Biff p f g a b -> Builder-showbBiffPrecWith2 = showbPrecWith2-{-# INLINE showbBiffPrecWith2 #-}+liftShowbBiffPrec2 = liftShowbPrec2+{-# INLINE liftShowbBiffPrec2 #-} -- | Convert a 'Clown' value to a 'Builder' with the given precedence. --@@ -69,13 +76,30 @@ showbClownPrec = showbPrec {-# INLINE showbClownPrec #-} --- | Convert a 'Clown' value to a 'Builder' with the given show function and precedence.+-- | Convert a 'Clown' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbClownPrecWith :: TextShow1 f => (Int -> a -> Builder) -> Int -> Clown f a b -> Builder-showbClownPrecWith sp = showbPrecWith2 sp undefined-{-# INLINE showbClownPrecWith #-}+-- /Since: 3/+liftShowbClownPrec :: TextShow1 f => (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> Clown f a b -> Builder+liftShowbClownPrec sp sl = liftShowbPrec2 sp sl undefined undefined+{-# INLINE liftShowbClownPrec #-} +-- | Convert a 'Fix' value to a 'Builder' with the given precedence.+--+-- /Since: 3/+showbFixPrec :: TextShow (p (Fix p a) a) => Int -> Fix p a -> Builder+showbFixPrec = showbPrec+{-# INLINE showbFixPrec #-}++-- | Convert a 'Fix' value to a 'Builder' with the given show functions and precedence.+--+-- /Since: 3/+liftShowbFixPrec :: TextShow2 p => (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> Fix p a -> Builder+liftShowbFixPrec sp sl p =+ liftShowbPrec2 (liftShowbPrec sp sl) (liftShowbList sp sl) sp sl p . out+{-# INLINE liftShowbFixPrec #-}+ -- | Convert a 'Flip' value to a 'Builder' with the given precedence. -- -- /Since: 2/@@ -85,12 +109,13 @@ -- | Convert a 'Flip' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbFlipPrecWith2 :: TextShow2 p- => (Int -> a -> Builder) -> (Int -> b -> Builder)+-- /Since: 3/+liftShowbFlipPrec2 :: TextShow2 p+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder) -> Int -> Flip p a b -> Builder-showbFlipPrecWith2 = showbPrecWith2-{-# INLINE showbFlipPrecWith2 #-}+liftShowbFlipPrec2 = liftShowbPrec2+{-# INLINE liftShowbFlipPrec2 #-} -- | Convert a 'Join' value to a 'Builder' with the given precedence. --@@ -99,12 +124,13 @@ showbJoinPrec = showbPrec {-# INLINE showbJoinPrec #-} --- | Convert a 'Join' value to a 'Builder' with the given show function and precedence.+-- | Convert a 'Join' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbJoinPrecWith :: TextShow2 p => (Int -> a -> Builder) -> Int -> Join p a -> Builder-showbJoinPrecWith sp p = showbPrecWith2 sp sp p . runJoin-{-# INLINE showbJoinPrecWith #-}+-- /Since: 3/+liftShowbJoinPrec :: TextShow2 p => (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> Join p a -> Builder+liftShowbJoinPrec sp sl p = liftShowbPrec2 sp sl sp sl p . runJoin+{-# INLINE liftShowbJoinPrec #-} -- | Convert a 'Joker' value to a 'Builder' with the given precedence. --@@ -113,30 +139,52 @@ showbJokerPrec = showbPrec {-# INLINE showbJokerPrec #-} --- | Convert a 'Joker' value to a 'Builder' with the given show function and precedence.+-- | Convert a 'Joker' value to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbJokerPrecWith :: TextShow1 g => (Int -> b -> Builder) -> Int -> Joker g a b -> Builder-showbJokerPrecWith sp = showbPrecWith2 undefined sp-{-# INLINE showbJokerPrecWith #-}+-- /Since: 3/+liftShowbJokerPrec :: TextShow1 g => (Int -> b -> Builder) -> ([b] -> Builder)+ -> Int -> Joker g a b -> Builder+liftShowbJokerPrec = liftShowbPrec2 undefined undefined+{-# INLINE liftShowbJokerPrec #-} -- | Convert a 'Product' value to a 'Builder' with the given precedence. -- -- /Since: 2/-showbProductPrec :: (TextShow (f a b), TextShow (g a b)) => Int -> Product f g a b -> Builder+showbProductPrec :: (TextShow (f a b), TextShow (g a b))+ => Int -> Product f g a b -> Builder showbProductPrec = showbPrec {-# INLINE showbProductPrec #-} -- | Convert a 'Product' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbProductPrecWith2 :: (TextShow2 f, TextShow2 g)- => (Int -> a -> Builder) -> (Int -> b -> Builder)+-- /Since: 3/+liftShowbProductPrec2 :: (TextShow2 f, TextShow2 g)+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder) -> Int -> Product f g a b -> Builder-showbProductPrecWith2 = showbPrecWith2-{-# INLINE showbProductPrecWith2 #-}+liftShowbProductPrec2 = liftShowbPrec2+{-# INLINE liftShowbProductPrec2 #-} +-- | Convert a 'Sum' value to a 'Builder' with the given precedence.+--+-- /Since: 3/+showbSumPrec :: (TextShow (f a b), TextShow (g a b))+ => Int -> Sum f g a b -> Builder+showbSumPrec = showbPrec+{-# INLINE showbSumPrec #-}++-- | Convert a 'Sum' value to a 'Builder' with the given show functions+-- and precedence.+--+-- /Since: 3/+liftShowbSumPrec2 :: (TextShow2 f, TextShow2 g)+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder)+ -> Int -> Sum f g a b -> Builder+liftShowbSumPrec2 = liftShowbPrec2+{-# INLINE liftShowbSumPrec2 #-}+ -- | Convert a 'Tannen' value to a 'Builder' with the given precedence. -- -- /Since: 2/@@ -147,12 +195,13 @@ -- | Convert a 'Tannen' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbTannenPrecWith2 :: (TextShow1 f, TextShow2 p)- => (Int -> a -> Builder) -> (Int -> b -> Builder)+-- /Since: 3/+liftShowbTannenPrec2 :: (TextShow1 f, TextShow2 p)+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder) -> Int -> Tannen f p a b -> Builder-showbTannenPrecWith2 = showbPrecWith2-{-# INLINE showbTannenPrecWith2 #-}+liftShowbTannenPrec2 = liftShowbPrec2+{-# INLINE liftShowbTannenPrec2 #-} -- | Convert a 'WrappedBifunctor' value to a 'Builder' with the given precedence. --@@ -164,55 +213,68 @@ -- | Convert a 'WrappedBifunctor' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbWrappedBifunctorPrecWith2 :: TextShow2 p- => (Int -> a -> Builder) -> (Int -> b -> Builder)+-- /Since: 3/+liftShowbWrappedBifunctorPrec2 :: TextShow2 p+ => (Int -> a -> Builder) -> ([a] -> Builder)+ -> (Int -> b -> Builder) -> ([b] -> Builder) -> Int -> WrappedBifunctor p a b -> Builder-showbWrappedBifunctorPrecWith2 = showbPrecWith2-{-# INLINE showbWrappedBifunctorPrecWith2 #-}+liftShowbWrappedBifunctorPrec2 = liftShowbPrec2+{-# INLINE liftShowbWrappedBifunctorPrec2 #-} instance TextShow (p (f a) (g b)) => TextShow (Biff p f g a b) where showbPrec = $(makeShowbPrec ''Biff) instance (TextShow2 p, TextShow1 f, TextShow1 g, TextShow a) => TextShow1 (Biff p f g a) where- showbPrecWith = showbPrecWith2 showbPrec+ liftShowbPrec = liftShowbPrec2 showbPrec showbList $(deriveTextShow2 ''Biff) instance TextShow (f a) => TextShow (Clown f a b) where showbPrec = $(makeShowbPrec ''Clown)-$(deriveTextShow1 ''Clown)+instance (TextShow1 f, TextShow a) => TextShow1 (Clown f a) where+ liftShowbPrec = $(makeLiftShowbPrec ''Clown) $(deriveTextShow2 ''Clown) +instance TextShow (p (Fix p a) a) => TextShow (Fix p a) where+ showbPrec = $(makeShowbPrec ''Fix)+instance TextShow2 p => TextShow1 (Fix p) where+ liftShowbPrec = liftShowbFixPrec+ instance TextShow (p b a) => TextShow (Flip p a b) where showbPrec = $(makeShowbPrec ''Flip) instance (TextShow2 p, TextShow a) => TextShow1 (Flip p a) where- showbPrecWith = showbPrecWith2 showbPrec+ liftShowbPrec = liftShowbPrec2 showbPrec showbList $(deriveTextShow2 ''Flip) instance TextShow (p a a) => TextShow (Join p a) where showbPrec = $(makeShowbPrec ''Join) instance TextShow2 p => TextShow1 (Join p) where- showbPrecWith = showbJoinPrecWith+ liftShowbPrec = liftShowbJoinPrec instance TextShow (g b) => TextShow (Joker g a b) where showbPrec = $(makeShowbPrec ''Joker) instance TextShow1 g => TextShow1 (Joker g a) where- showbPrecWith = $(makeShowbPrecWith ''Joker)+ liftShowbPrec = $(makeLiftShowbPrec ''Joker) $(deriveTextShow2 ''Joker) instance (TextShow (f a b), TextShow (g a b)) => TextShow (Product f g a b) where showbPrec = $(makeShowbPrec ''Product) instance (TextShow2 f, TextShow2 g, TextShow a) => TextShow1 (Product f g a) where- showbPrecWith = showbPrecWith2 showbPrec+ liftShowbPrec = liftShowbPrec2 showbPrec showbList $(deriveTextShow2 ''Product) +instance (TextShow (f a b), TextShow (g a b)) => TextShow (Sum f g a b) where+ showbPrec = $(makeShowbPrec ''Sum)+instance (TextShow2 f, TextShow2 g, TextShow a) => TextShow1 (Sum f g a) where+ liftShowbPrec = liftShowbPrec2 showbPrec showbList+$(deriveTextShow2 ''Sum)+ instance TextShow (f (p a b)) => TextShow (Tannen f p a b) where showbPrec = $(makeShowbPrec ''Tannen) instance (TextShow1 f, TextShow2 p, TextShow a) => TextShow1 (Tannen f p a) where- showbPrecWith = showbPrecWith2 showbPrec+ liftShowbPrec = liftShowbPrec2 showbPrec showbList $(deriveTextShow2 ''Tannen) instance TextShow (p a b) => TextShow (WrappedBifunctor p a b) where showbPrec = $(makeShowbPrec ''WrappedBifunctor) instance (TextShow2 p, TextShow a) => TextShow1 (WrappedBifunctor p a) where- showbPrecWith = showbPrecWith2 showbPrec+ liftShowbPrec = liftShowbPrec2 showbPrec showbList $(deriveTextShow2 ''WrappedBifunctor)
src/TextShow/Data/Binary.hs view
@@ -14,7 +14,7 @@ /Since: 2/ -}-module TextShow.Data.Binary (showbDecoderWith) where+module TextShow.Data.Binary (liftShowbDecoder) where import Data.Binary.Get.Internal (Decoder(..)) import Data.Monoid.Compat@@ -25,17 +25,17 @@ -- | Convert a 'Decoder' to a 'Builder' with the given show function. ----- /Since: 2/-showbDecoderWith :: (a -> Builder) -> Decoder a -> Builder-showbDecoderWith _ (Fail _ msg) = "Fail: " <> fromString msg-showbDecoderWith _ (Partial _) = "Partial _"-showbDecoderWith sp (Done _ a) = "Done: " <> sp a-showbDecoderWith _ (BytesRead _ _) = "BytesRead"+-- /Since: 3/+liftShowbDecoder :: (a -> Builder) -> Decoder a -> Builder+liftShowbDecoder _ (Fail _ msg) = "Fail: " <> fromString msg+liftShowbDecoder _ (Partial _) = "Partial _"+liftShowbDecoder sp (Done _ a) = "Done: " <> sp a+liftShowbDecoder _ (BytesRead _ _) = "BytesRead" instance TextShow a => TextShow (Decoder a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 Decoder where- showbPrecWith sp _ = showbDecoderWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec sp _ _ = liftShowbDecoder $ sp 0+ INLINE_INST_FUN(liftShowbPrec)
src/TextShow/Data/Containers.hs view
@@ -14,19 +14,14 @@ /Since: 2/ -} module TextShow.Data.Containers (- showbIntMapPrecWith+ liftShowbIntMapPrec , showbIntSetPrec- , showbMapPrecWith2- , showbSequencePrec- , showbSequencePrecWith- , showbViewLPrec- , showbViewLPrecWith- , showbViewRPrec- , showbViewRPrecWith- , showbSetPrec- , showbSetPrecWith- , showbTreePrec- , showbTreePrecWith+ , liftShowbMapPrec2+ , liftShowbSequencePrec+ , liftShowbViewLPrec+ , liftShowbViewRPrec+ , liftShowbSetPrec+ , liftShowbTreePrec ) where import qualified Data.Foldable as F@@ -42,113 +37,84 @@ import Data.Set (Set) import Data.Tree (Tree) -import TextShow (TextShow(showb, showbPrec), TextShow1(..), TextShow2(..),+import TextShow (TextShow(..), TextShow1(..), TextShow2(..), Builder, showbPrec1) import TextShow.Data.Integral ()-import TextShow.Data.Tuple (showb2TupleWith2) import TextShow.TH (deriveTextShow, deriveTextShow1)-import TextShow.Utils (showbUnaryList, showbUnaryListWith)+import TextShow.Utils (showbUnaryListWith) #include "inline.h" -- | Convert an 'IntMap' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbIntMapPrecWith :: (v -> Builder) -> Int -> IntMap v -> Builder-showbIntMapPrecWith sp p = showbUnaryListWith (showb2TupleWith2 showb sp) p . IM.toList-{-# INLINE showbIntMapPrecWith #-}+-- /Since: 3/+liftShowbIntMapPrec :: (v -> Builder) -> Int -> IntMap v -> Builder+liftShowbIntMapPrec sp p =+ showbUnaryListWith (liftShowbList2 showbPrec undefined+ (const sp) undefined) p . IM.toList+{-# INLINE liftShowbIntMapPrec #-} -- | Convert an 'IntSet' to a 'Builder' with the given precedence. -- -- /Since: 2/ showbIntSetPrec :: Int -> IntSet -> Builder-showbIntSetPrec p = showbUnaryListWith showb p . IS.toList+showbIntSetPrec p = showbUnaryListWith showbList p . IS.toList {-# INLINE showbIntSetPrec #-} -- | Convert a 'Map' to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbMapPrecWith2 :: (k -> Builder) -> (v -> Builder) -> Int -> Map k v -> Builder-showbMapPrecWith2 sp1 sp2 p = showbUnaryListWith (showb2TupleWith2 sp1 sp2) p . M.toList-{-# INLINE showbMapPrecWith2 #-}---- | Convert a 'Sequence' to a 'Builder' with the given precedence.------ /Since: 2/-showbSequencePrec :: TextShow a => Int -> Seq a -> Builder-showbSequencePrec p = showbUnaryList p . F.toList-{-# INLINE showbSequencePrec #-}+-- /Since: 3/+liftShowbMapPrec2 :: (k -> Builder) -> (v -> Builder) -> Int -> Map k v -> Builder+liftShowbMapPrec2 sp1 sp2 p =+ showbUnaryListWith (liftShowbList2 (const sp1) undefined+ (const sp2) undefined) p . M.toList+{-# INLINE liftShowbMapPrec2 #-} -- | Convert a 'Sequence' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbSequencePrecWith :: (a -> Builder) -> Int -> Seq a -> Builder-showbSequencePrecWith sp p = showbUnaryListWith sp p . F.toList-{-# INLINE showbSequencePrecWith #-}---- | Convert a 'ViewL' value to a 'Builder' with the given precedence.------ /Since: 2/-showbViewLPrec :: TextShow a => Int -> ViewL a -> Builder-showbViewLPrec = showbPrec-{-# INLINE showbViewLPrec #-}+-- /Since: 3/+liftShowbSequencePrec :: ([a] -> Builder) -> Int -> Seq a -> Builder+liftShowbSequencePrec sl p = showbUnaryListWith sl p . F.toList+{-# INLINE liftShowbSequencePrec #-} -- | Convert a 'ViewL' value to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbViewLPrecWith :: (a -> Builder) -> Int -> ViewL a -> Builder-showbViewLPrecWith sp = showbPrecWith $ const sp-{-# INLINE showbViewLPrecWith #-}---- | Convert a 'ViewR' value to a 'Builder' with the given precedence.------ /Since: 2/-showbViewRPrec :: TextShow a => Int -> ViewR a -> Builder-showbViewRPrec = showbPrec-{-# INLINE showbViewRPrec #-}+-- /Since: 3/+liftShowbViewLPrec :: (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> ViewL a -> Builder+liftShowbViewLPrec = liftShowbPrec+{-# INLINE liftShowbViewLPrec #-} -- | Convert a 'ViewR' value to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbViewRPrecWith :: (a -> Builder) -> Int -> ViewR a -> Builder-showbViewRPrecWith sp = showbPrecWith $ const sp-{-# INLINE showbViewRPrecWith #-}---- | Convert a 'Set' to a 'Builder' with the given precedence.------ /Since: 2/-showbSetPrec :: TextShow a => Int -> Set a -> Builder-showbSetPrec p = showbUnaryList p . Set.toList-{-# INLINE showbSetPrec #-}+-- /Since: 3/+liftShowbViewRPrec :: (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> ViewR a -> Builder+liftShowbViewRPrec = liftShowbPrec+{-# INLINE liftShowbViewRPrec #-} -- | Convert a 'Set' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbSetPrecWith :: (a -> Builder) -> Int -> Set a -> Builder-showbSetPrecWith sp p = showbUnaryListWith sp p . Set.toList-{-# INLINE showbSetPrecWith #-}---- | Convert a 'Tree' to a 'Builder' with the given precedence.------ /Since: 2/-showbTreePrec :: TextShow a => Int -> Tree a -> Builder-showbTreePrec = showbPrec-{-# INLINE showbTreePrec #-}+-- /Since: 3/+liftShowbSetPrec :: ([a] -> Builder) -> Int -> Set a -> Builder+liftShowbSetPrec sl p = showbUnaryListWith sl p . Set.toList+{-# INLINE liftShowbSetPrec #-} --- | Convert a 'Tree' to a 'Builder' with the given show function and precedence.+-- | Convert a 'Tree' to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbTreePrecWith :: (a -> Builder) -> Int -> Tree a -> Builder-showbTreePrecWith sp = showbPrecWith $ const sp-{-# INLINE showbTreePrecWith #-}+-- /Since: 3/+liftShowbTreePrec :: (Int -> a -> Builder) -> ([a] -> Builder)+ -> Int -> Tree a -> Builder+liftShowbTreePrec = liftShowbPrec+{-# INLINE liftShowbTreePrec #-} instance TextShow v => TextShow (IntMap v) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 IntMap where- showbPrecWith sp = showbIntMapPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec sp _ = liftShowbIntMapPrec (sp 0)+ INLINE_INST_FUN(liftShowbPrec) instance TextShow IntSet where showbPrec = showbIntSetPrec@@ -159,20 +125,20 @@ INLINE_INST_FUN(showbPrec) instance TextShow k => TextShow1 (Map k) where- showbPrecWith = showbPrecWith2 showbPrec- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbPrec2 showbPrec showbList+ INLINE_INST_FUN(liftShowbPrec) instance TextShow2 Map where- showbPrecWith2 sp1 sp2 = showbMapPrecWith2 (sp1 0) (sp2 0)- INLINE_INST_FUN(showbPrecWith2)+ liftShowbPrec2 sp1 _ sp2 _ = liftShowbMapPrec2 (sp1 0) (sp2 0)+ INLINE_INST_FUN(liftShowbPrec2) instance TextShow a => TextShow (Seq a) where- showbPrec = showbSequencePrec+ showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 Seq where- showbPrecWith sp = showbSequencePrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec _ = liftShowbSequencePrec+ INLINE_INST_FUN(liftShowbPrec) $(deriveTextShow ''ViewL) $(deriveTextShow1 ''ViewL)@@ -181,12 +147,12 @@ $(deriveTextShow1 ''ViewR) instance TextShow a => TextShow (Set a) where- showbPrec = showbSetPrec+ showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 Set where- showbPrecWith sp = showbSetPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec _ = liftShowbSetPrec+ INLINE_INST_FUN(liftShowbPrec) $(deriveTextShow ''Tree) $(deriveTextShow1 ''Tree)
src/TextShow/Data/Functor/Trans.hs view
@@ -14,121 +14,63 @@ Stability: Provisional Portability: GHC -Monomorphic 'TextShow' functions for functor transformers. Note that an instance for-the 'Identity' transformer is found in @text-show@, since it is a part of-@base-4.8.0.0@ and later.+Monomorphic 'TextShow' functions for functor transformers. +Note that :++* An instance for 'Identity' is found in @text-show@, since it is a part of+ @base-4.8.0.0@ and later.++* Instances for 'Compose', 'Product', and 'Sum' are found in @text-show@, since they+ are part of @base-4.9.0.0@ and later.+ /Since: 2/ -}-module TextShow.Data.Functor.Trans (- showbComposePrecWith- , showbConstantPrecWith- , showbProductPrecWith- , showbReversePrecWith- , showbSumPrecWith- ) where+module TextShow.Data.Functor.Trans (liftShowbConstantPrec, liftShowbReversePrec) where -import Data.Functor.Compose (Compose(..)) import Data.Functor.Constant (Constant(..))-import Data.Functor.Product (Product(..)) import Data.Functor.Reverse (Reverse(..))-import Data.Functor.Sum (Sum(..)) -import TextShow (TextShow(showbPrec), TextShow1(..), TextShow2(..),- Builder, showbPrec1, showbUnaryWith, showbBinaryWith)+import TextShow (TextShow(..), TextShow1(..), TextShow2(..),+ Builder, showbPrec1, showbUnaryWith) #include "inline.h" --- | Convert a 'Compose' value to a 'Builder' with the given show function--- and precedence.------ /Since: 2/-showbComposePrecWith :: (TextShow1 f, TextShow1 g)- => (Int -> a -> Builder)- -> Int -> Compose f g a -> Builder-showbComposePrecWith sp p (Compose x) =- showbUnaryWith (showbPrecWith (showbPrecWith sp)) "Compose" p x-{-# INLINE showbComposePrecWith #-}- -- | Convert a 'Constant' value to a 'Builder' with the given show function -- and precedence. ----- /Since: 2/-showbConstantPrecWith :: (Int -> a -> Builder) -> Int -> Constant a b -> Builder-showbConstantPrecWith sp p (Constant x) = showbUnaryWith sp "Constant" p x-{-# INLINE showbConstantPrecWith #-}---- | Convert a 'Product' value to a 'Builder' with the given show function--- and precedence.------ /Since: 2/-showbProductPrecWith :: (TextShow1 f, TextShow1 g)- => (Int -> a -> Builder)- -> Int -> Product f g a -> Builder-showbProductPrecWith sp p (Pair x y) =- showbBinaryWith (showbPrecWith sp) (showbPrecWith sp) "Pair" p x y-{-# INLINE showbProductPrecWith #-}+-- /Since: 3/+liftShowbConstantPrec :: (Int -> a -> Builder) -> Int -> Constant a b -> Builder+liftShowbConstantPrec sp p (Constant x) = showbUnaryWith sp "Constant" p x+{-# INLINE liftShowbConstantPrec #-} --- | Convert a 'Reverse' value to a 'Builder' with the given show function+-- | Convert a 'Reverse' value to a 'Builder' with the given show functions -- and precedence. ----- /Since: 2/-showbReversePrecWith :: TextShow1 f- => (Int -> a -> Builder)+-- /Since: 3/+liftShowbReversePrec :: TextShow1 f+ => (Int -> a -> Builder) -> ([a] -> Builder) -> Int -> Reverse f a -> Builder-showbReversePrecWith sp p (Reverse x) = showbUnaryWith (showbPrecWith sp) "Reverse" p x-{-# INLINE showbReversePrecWith #-}---- | Convert a 'Sum' value to a 'Builder' with the given show function and precedence.------ /Since: 2/-showbSumPrecWith :: (TextShow1 f, TextShow1 g)- => (Int -> a -> Builder)- -> Int -> Sum f g a -> Builder-showbSumPrecWith sp p (InL x) = showbUnaryWith (showbPrecWith sp) "InL" p x-showbSumPrecWith sp p (InR y) = showbUnaryWith (showbPrecWith sp) "InR" p y-{-# INLINE showbSumPrecWith #-}--instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Compose f g a) where- showbPrec = showbPrec1- INLINE_INST_FUN(showbPrec)--instance (TextShow1 f, TextShow1 g) => TextShow1 (Compose f g) where- showbPrecWith = showbComposePrecWith- INLINE_INST_FUN(showbPrecWith)+liftShowbReversePrec sp sl p (Reverse x) =+ showbUnaryWith (liftShowbPrec sp sl) "Reverse" p x+{-# INLINE liftShowbReversePrec #-} instance TextShow a => TextShow (Constant a b) where- showbPrec = showbConstantPrecWith showbPrec+ showbPrec = liftShowbConstantPrec showbPrec INLINE_INST_FUN(showbPrec) instance TextShow a => TextShow1 (Constant a) where- showbPrecWith = showbPrecWith2 showbPrec- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec _ _ = liftShowbConstantPrec showbPrec+ INLINE_INST_FUN(liftShowbPrec) instance TextShow2 Constant where- showbPrecWith2 sp _ = showbConstantPrecWith sp- INLINE_INST_FUN(showbPrecWith2)--instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Product f g a) where- showbPrec = showbPrec1- INLINE_INST_FUN(showbPrec)--instance (TextShow1 f, TextShow1 g) => TextShow1 (Product f g) where- showbPrecWith = showbProductPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec2 sp _ _ _ = liftShowbConstantPrec sp+ INLINE_INST_FUN(liftShowbPrec2) instance (TextShow1 f, TextShow a) => TextShow (Reverse f a) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 f => TextShow1 (Reverse f) where- showbPrecWith = showbReversePrecWith- INLINE_INST_FUN(showbPrecWith)--instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Sum f g a) where- showbPrec = showbPrec1- INLINE_INST_FUN(showbPrec)--instance (TextShow1 f, TextShow1 g) => TextShow1 (Sum f g) where- showbPrecWith = showbSumPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbReversePrec+ INLINE_INST_FUN(liftShowbPrec)
− src/TextShow/Data/List/NonEmpty.hs
@@ -1,31 +0,0 @@-{-# LANGUAGE TemplateHaskell #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-|-Module: TextShow.Data.List.NonEmpty-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--Monomorphic 'TextShow' function for 'NonEmpty' lists.--/Since: 2/--}-module TextShow.Data.List.NonEmpty (showbNonEmptyPrecWith) where--import Data.List.NonEmpty (NonEmpty)--import TextShow (Builder, showbPrecWith)-import TextShow.TH (deriveTextShow, deriveTextShow1)---- | Convert a 'NonEmpty' list to a 'Builder' with the given show function--- and precedence.------ /Since: 2/-showbNonEmptyPrecWith :: (Int -> a -> Builder) -> Int -> NonEmpty a -> Builder-showbNonEmptyPrecWith = showbPrecWith-{-# INLINE showbNonEmptyPrecWith #-}--$(deriveTextShow ''NonEmpty)-$(deriveTextShow1 ''NonEmpty)
− src/TextShow/Data/Semigroup.hs
@@ -1,105 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE TemplateHaskell #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-|-Module: TextShow.Data.Semigroup-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--Monomorphic 'TextShow' functions for @Semigroup@ data types.--/Since: 2/--}-module TextShow.Data.Semigroup (- showbMinPrecWith- , showbMaxPrecWith- , showbFirstPrecWith- , showbLastPrecWith- , showbWrappedMonoidPrecWith- , showbOptionPrecWith- , showbArgPrecWith2- ) where--import Data.Semigroup (Min, Max, First, Last, WrappedMonoid, Option, Arg)--import TextShow (Builder, showbPrecWith, showbPrecWith2)-import TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2)--#include "inline.h"---- | Convert a 'Min' value to a 'Builder' with the given show function and precedence.------ /Since: 2/-showbMinPrecWith :: (Int -> a -> Builder) -> Int -> Min a -> Builder-showbMinPrecWith = showbPrecWith-{-# INLINE showbMinPrecWith #-}---- | Convert a 'Max' value to a 'Builder' with the given show function and precedence.------ /Since: 2/-showbMaxPrecWith :: (Int -> a -> Builder) -> Int -> Max a -> Builder-showbMaxPrecWith = showbPrecWith-{-# INLINE showbMaxPrecWith #-}---- | Convert a 'First' value to a 'Builder' with the given show function and precedence.------ /Since: 2/-showbFirstPrecWith :: (Int -> a -> Builder) -> Int -> First a -> Builder-showbFirstPrecWith = showbPrecWith-{-# INLINE showbFirstPrecWith #-}---- | Convert a 'Last' value to a 'Builder' with the given show function and precedence.------ /Since: 2/-showbLastPrecWith :: (Int -> a -> Builder) -> Int -> Last a -> Builder-showbLastPrecWith = showbPrecWith-{-# INLINE showbLastPrecWith #-}---- | Convert a 'WrappedMonoid' to a 'Builder' with the given show function--- and precedence.------ /Since: 2/-showbWrappedMonoidPrecWith :: (Int -> m -> Builder) -> Int -> WrappedMonoid m -> Builder-showbWrappedMonoidPrecWith = showbPrecWith-{-# INLINE showbWrappedMonoidPrecWith #-}---- | Convert an 'Option' value to a 'Builder' with the given show function--- and precedence.------ /Since: 2/-showbOptionPrecWith :: (Int -> a -> Builder) -> Int -> Option a -> Builder-showbOptionPrecWith = showbPrecWith-{-# INLINE showbOptionPrecWith #-}---- | Convert an 'Arg' value to a 'Builder' with the given show functions and precedence.------ /Since: 2/-showbArgPrecWith2 :: (Int -> a -> Builder) -> (Int -> b -> Builder)- -> Int -> Arg a b -> Builder-showbArgPrecWith2 = showbPrecWith2-{-# INLINE showbArgPrecWith2 #-}--$(deriveTextShow ''Min)-$(deriveTextShow1 ''Min)--$(deriveTextShow ''Max)-$(deriveTextShow1 ''Max)--$(deriveTextShow ''First)-$(deriveTextShow1 ''First)--$(deriveTextShow ''Last)-$(deriveTextShow1 ''Last)--$(deriveTextShow ''WrappedMonoid)-$(deriveTextShow1 ''WrappedMonoid)--$(deriveTextShow ''Option)-$(deriveTextShow1 ''Option)--$(deriveTextShow ''Arg)-$(deriveTextShow1 ''Arg)-$(deriveTextShow2 ''Arg)
src/TextShow/Data/Tagged.hs view
@@ -18,29 +18,29 @@ /Since: 2/ -}-module TextShow.Data.Tagged (showbTaggedPrecWith) where+module TextShow.Data.Tagged (liftShowbTaggedPrec) where import Data.Tagged (Tagged(..))-import TextShow (TextShow(showbPrec), TextShow1(..), TextShow2(..),+import TextShow (TextShow(..), TextShow1(..), TextShow2(..), Builder, showbPrec1, showbUnaryWith) #include "inline.h" -- | Convert a 'Tagged' value to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbTaggedPrecWith :: (Int -> b -> Builder) -> Int -> Tagged s b -> Builder-showbTaggedPrecWith sp p (Tagged b) = showbUnaryWith sp "Tagged" p b-{-# INLINE showbTaggedPrecWith #-}+-- /Since: 3/+liftShowbTaggedPrec :: (Int -> b -> Builder) -> Int -> Tagged s b -> Builder+liftShowbTaggedPrec sp p (Tagged b) = showbUnaryWith sp "Tagged" p b+{-# INLINE liftShowbTaggedPrec #-} instance TextShow b => TextShow (Tagged s b) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 (Tagged s) where- showbPrecWith = showbTaggedPrecWith- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec sp _ = liftShowbTaggedPrec sp+ INLINE_INST_FUN(liftShowbPrec) instance TextShow2 Tagged where- showbPrecWith2 _ = showbTaggedPrecWith- INLINE_INST_FUN(showbPrecWith2)+ liftShowbPrec2 _ _ sp _ = liftShowbTaggedPrec sp+ INLINE_INST_FUN(liftShowbPrec2)
src/TextShow/Data/Time.hs view
@@ -33,6 +33,7 @@ import Data.Fixed (Pico) import Data.Monoid.Compat+import Data.Semigroup (mtimesDefault) import Data.Time.Calendar (Day, toGregorian) import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime) import Data.Time.Clock.TAI (AbsoluteTime, taiToUTCTime)@@ -40,16 +41,13 @@ import Data.Time.LocalTime (TimeZone(..), TimeOfDay(..), LocalTime(..), ZonedTime(..), utc, utcToLocalTime, utcToZonedTime) -import TextShow (TextShow(showb), Builder, FromStringShow(..),+import TextShow (TextShow(..), Builder, FromStringShow(..), fromString, lengthB, showbSpace, singleton) import TextShow.Data.Fixed (showbFixed) import TextShow.Data.Integral ()-import TextShow.Utils (mtimesDefault) #if MIN_VERSION_time(1,5,0) import Data.Time.Format (TimeLocale)--import TextShow (showbPrec) import TextShow.TH (deriveTextShow) #endif
src/TextShow/Data/UnorderedContainers.hs view
@@ -13,9 +13,8 @@ /Since: 2/ -} module TextShow.Data.UnorderedContainers (- showbHashMapPrecWith2- , showbHashSetPrec- , showbHashSetPrecWith+ liftShowbHashMapPrec2+ , liftShowbHashSetPrec ) where import qualified Data.HashMap.Lazy as HM (toList)@@ -23,52 +22,45 @@ import qualified Data.HashSet as HS (toList) import Data.HashSet (HashSet) -import TextShow (TextShow(showbPrec), TextShow1(..), TextShow2(..),+import TextShow (TextShow(..), TextShow1(..), TextShow2(..), Builder, showbPrec1)-import TextShow.Data.Tuple (showb2TupleWith2)-import TextShow.Utils (showbUnaryList, showbUnaryListWith)+import TextShow.Utils (showbUnaryListWith) #include "inline.h" -- | Convert a 'HashMap' to a 'Builder' with the given show functions and precedence. ----- /Since: 2/-showbHashMapPrecWith2 :: (k -> Builder) -> (v -> Builder)+-- /Since: 3/+liftShowbHashMapPrec2 :: (k -> Builder) -> (v -> Builder) -> Int -> HashMap k v -> Builder-showbHashMapPrecWith2 sp1 sp2 p =- showbUnaryListWith (showb2TupleWith2 sp1 sp2) p . HM.toList-{-# INLINE showbHashMapPrecWith2 #-}---- | Convert a 'HashSet' to a 'Builder' with the given precedence.------ /Since: 2/-showbHashSetPrec :: TextShow a => Int -> HashSet a -> Builder-showbHashSetPrec p = showbUnaryList p . HS.toList-{-# INLINE showbHashSetPrec #-}+liftShowbHashMapPrec2 sp1 sp2 p =+ showbUnaryListWith (liftShowbList2 (const sp1) undefined+ (const sp2) undefined) p . HM.toList+{-# INLINE liftShowbHashMapPrec2 #-} -- | Convert a 'HashSet' to a 'Builder' with the given show function and precedence. ----- /Since: 2/-showbHashSetPrecWith :: (a -> Builder) -> Int -> HashSet a -> Builder-showbHashSetPrecWith sp p = showbUnaryListWith sp p . HS.toList-{-# INLINE showbHashSetPrecWith #-}+-- /Since: 3/+liftShowbHashSetPrec :: ([a] -> Builder) -> Int -> HashSet a -> Builder+liftShowbHashSetPrec sl p = showbUnaryListWith sl p . HS.toList+{-# INLINE liftShowbHashSetPrec #-} instance (TextShow k, TextShow v) => TextShow (HashMap k v) where showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow k => TextShow1 (HashMap k) where- showbPrecWith = showbPrecWith2 showbPrec- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec = liftShowbPrec2 showbPrec showbList+ INLINE_INST_FUN(liftShowbPrec) instance TextShow2 HashMap where- showbPrecWith2 sp1 sp2 = showbHashMapPrecWith2 (sp1 0) (sp2 0)- INLINE_INST_FUN(showbPrecWith2)+ liftShowbPrec2 sp1 _ sp2 _ = liftShowbHashMapPrec2 (sp1 0) (sp2 0)+ INLINE_INST_FUN(liftShowbPrec2) instance TextShow a => TextShow (HashSet a) where- showbPrec = showbHashSetPrec+ showbPrec = showbPrec1 INLINE_INST_FUN(showbPrec) instance TextShow1 HashSet where- showbPrecWith sp = showbHashSetPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec _ = liftShowbHashSetPrec+ INLINE_INST_FUN(liftShowbPrec)
src/TextShow/Data/Vector.hs view
@@ -14,10 +14,9 @@ /Since: 2/ -} module TextShow.Data.Vector (- showbVectorPrec- , showbVectorPrecWith+ liftShowbVectorPrec , showbVectorGenericPrec- , showbVectorGenericPrecWith+ , liftShowbVectorGenericPrec , showbVectorPrimitivePrec , showbVectorStorablePrec , showbVectorUnboxedPrec@@ -48,22 +47,14 @@ #include "inline.h" --- | Convert a boxed 'B.Vector' to a 'Builder' with the given precedence.--- Note that with @vector-0.11@ and above, the precedence argument is ignored.------ /Since: 2/-showbVectorPrec :: TextShow a => Int -> B.Vector a -> Builder-showbVectorPrec = showbVectorGenericPrec-{-# INLINE showbVectorPrec #-}- -- | Convert a boxed 'B.Vector' to a 'Builder' with the given show function -- and precedence. -- Note that with @vector-0.11@ and above, the precedence argument is ignored. ----- /Since: 2/-showbVectorPrecWith :: (a -> Builder) -> Int -> B.Vector a -> Builder-showbVectorPrecWith = showbVectorGenericPrecWith-{-# INLINE showbVectorPrecWith #-}+-- /Since: 3/+liftShowbVectorPrec :: ([a] -> Builder) -> Int -> B.Vector a -> Builder+liftShowbVectorPrec = liftShowbVectorGenericPrec+{-# INLINE liftShowbVectorPrec #-} -- | Convert a generic 'G.Vector' to a 'Builder' with the given precedence. -- Note that with @vector-0.11@ and above, the precedence argument is ignored.@@ -71,9 +62,9 @@ -- /Since: 2/ showbVectorGenericPrec :: (G.Vector v a, TextShow a) => Int -> v a -> Builder #if MIN_VERSION_vector(0,11,0)-showbVectorGenericPrec _ = showb . toList+showbVectorGenericPrec _ = showbList . toList #else-showbVectorGenericPrec p = showbUnaryList p . toList+showbVectorGenericPrec p = showbUnaryListWith showbList p . toList #endif {-# INLINE showbVectorGenericPrec #-} @@ -81,14 +72,14 @@ -- and precedence. -- Note that with @vector-0.11@ and above, the precedence argument is ignored. ----- /Since: 2/-showbVectorGenericPrecWith :: G.Vector v a => (a -> Builder) -> Int -> v a -> Builder+-- /Since: 3/+liftShowbVectorGenericPrec :: G.Vector v a => ([a] -> Builder) -> Int -> v a -> Builder #if MIN_VERSION_vector(0,11,0)-showbVectorGenericPrecWith sp p = showbPrecWith (const sp) p . toList+liftShowbVectorGenericPrec sl _ = sl . toList #else-showbVectorGenericPrecWith sp p = showbUnaryListWith sp p . toList+liftShowbVectorGenericPrec sl p = showbUnaryListWith sl p . toList #endif-{-# INLINE showbVectorGenericPrecWith #-}+{-# INLINE liftShowbVectorGenericPrec #-} -- | Convert a primitive 'P.Vector' to a 'Builder' with the given precedence. -- Note that with @vector-0.11@ and above, the precedence argument is ignored.@@ -122,12 +113,12 @@ {-# INLINE showbSizePrec #-} instance TextShow a => TextShow (B.Vector a) where- showbPrec = showbVectorPrec+ showbPrec = showbVectorGenericPrec INLINE_INST_FUN(showbPrec) instance TextShow1 B.Vector where- showbPrecWith sp = showbVectorPrecWith $ sp 0- INLINE_INST_FUN(showbPrecWith)+ liftShowbPrec _ sl = liftShowbVectorPrec sl+ INLINE_INST_FUN(liftShowbPrec) instance (TextShow a, Prim a) => TextShow (P.Vector a) where showbPrec = showbVectorPrimitivePrec
src/TextShow/Instances.hs view
@@ -37,8 +37,6 @@ import TextShow.Data.Binary () import TextShow.Data.Containers () import TextShow.Data.Functor.Trans ()-import TextShow.Data.List.NonEmpty ()-import TextShow.Data.Semigroup () import TextShow.Data.Tagged () import TextShow.Data.Time () import TextShow.Data.UnorderedContainers ()
src/TextShow/Language/Haskell/TH.hs view
@@ -1,10 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MagicHash #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeSynonymInstances #-}-#if !(MIN_VERSION_template_haskell(2,10,0))-{-# LANGUAGE MagicHash #-}-#endif {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module: TextShow.Language.Haskell.TH@@ -23,6 +21,9 @@ showbAnnLookupPrec , showbAnnTargetPrec, #endif+#if MIN_VERSION_template_haskell(2,11,0)+ showbBangPrec,+#endif showbBodyPrec , showbCallconv #if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))@@ -30,15 +31,24 @@ #endif , showbClausePrec , showbConPrec+#if MIN_VERSION_template_haskell(2,11,0)+ , showbDecidedStrictness+#endif , showbDecPrec , showbExpPrec , showbFamFlavour+#if MIN_VERSION_template_haskell(2,11,0)+ , showbFamilyResultSigPrec+#endif , showbFixityPrec , showbFixityDirection , showbForeignPrec , showbFunDepPrec , showbGuardPrec , showbInfoPrec+#if MIN_VERSION_template_haskell(2,11,0)+ , showbInjectivityAnnPrec+#endif #if MIN_VERSION_template_haskell(2,8,0) , showbInline #else@@ -72,16 +82,23 @@ , showbRuleMatch #endif , showbSafety+#if MIN_VERSION_template_haskell(2,11,0)+ , showbSourceStrictness+ , showbSourceUnpackedness+#endif , showbStmtPrec- , showbStrict+ , showbStrictPrec+#if MIN_VERSION_template_haskell(2,11,0)+ , showbTypeFamilyHeadPrec+#endif #if MIN_VERSION_template_haskell(2,8,0) , showbTyLitPrec #endif , showbTypePrec- , showbTyVarBndrPrec #if MIN_VERSION_template_haskell(2,9,0) , showbTySynEqnPrec #endif+ , showbTyVarBndrPrec , showbDoc ) where @@ -98,7 +115,7 @@ import Language.Haskell.TH.PprLib (Doc, to_HPJ_Doc) import Language.Haskell.TH.Syntax -import TextShow (TextShow(showb, showbPrec), Builder,+import TextShow (TextShow(..), Builder, fromString, singleton, toLazyText) import TextShow.Data.Integral (showbIntPrec) import TextShow.Text.PrettyPrint (renderB)@@ -330,11 +347,18 @@ showbStmtPrec :: Int -> Stmt -> Builder showbStmtPrec = showbPrec --- | Convert a 'Strict' to a 'Builder'.+-- | Convert a 'Strict' to a 'Builder' with the given precedence.+-- Note that 'Strict' is a type synonym for 'Bang' on @template-haskell-2.11.0.0@+-- and later, and precedence matters for 'Bang'. On earlier versions of+-- @template-haskell@, however, the precedence argument is ignored. ----- /Since: 2/-showbStrict :: Strict -> Builder-showbStrict = showb+-- /Since: 3/+showbStrictPrec :: Int -> Strict -> Builder+#if MIN_VERSION_template_haskell(2,11,0)+showbStrictPrec = showbBangPrec+#else+showbStrictPrec = showbPrec+#endif -- | Convert a 'Type' to a 'Builder' with the given precedence. --@@ -451,6 +475,57 @@ showbTySynEqnPrec = showbPrec #endif +#if MIN_VERSION_template_haskell(2,11,0)+-- | Convert a 'Bang' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbBangPrec :: Int -> Bang -> Builder+showbBangPrec = showbPrec++-- | Convert a 'DecidedStrictness' to a 'Builder'.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbDecidedStrictness :: DecidedStrictness -> Builder+showbDecidedStrictness = showb++-- | Convert a 'FamilyResultSig' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbFamilyResultSigPrec :: Int -> FamilyResultSig -> Builder+showbFamilyResultSigPrec = showbPrec++-- | Convert an 'InjectivityAnn' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbInjectivityAnnPrec :: Int -> InjectivityAnn -> Builder+showbInjectivityAnnPrec = showbPrec++-- | Convert a 'SourceStrictness' to a 'Builder'.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbSourceStrictness :: SourceStrictness -> Builder+showbSourceStrictness = showb++-- | Convert a 'SourceUnpackedness' to a 'Builder'.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbSourceUnpackedness :: SourceUnpackedness -> Builder+showbSourceUnpackedness = showb++-- | Convert an 'TypeFamilyHead' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.11.0.0@ or later.+--+-- /Since: 3/+showbTypeFamilyHeadPrec :: Int -> TypeFamilyHead -> Builder+showbTypeFamilyHeadPrec = showbPrec+#endif+ $(deriveTextShow ''Body) $(deriveTextShow ''Callconv) $(deriveTextShow ''Clause)@@ -479,7 +554,6 @@ $(deriveTextShow ''Range) $(deriveTextShow ''Safety) $(deriveTextShow ''Stmt)-$(deriveTextShow ''Strict) $(deriveTextShow ''Type) $(deriveTextShow ''TyVarBndr) @@ -512,4 +586,16 @@ #if !(MIN_VERSION_template_haskell(2,10,0)) $(deriveTextShow ''Pred)+#endif++#if MIN_VERSION_template_haskell(2,11,0)+$(deriveTextShow ''Bang)+$(deriveTextShow ''DecidedStrictness)+$(deriveTextShow ''FamilyResultSig)+$(deriveTextShow ''InjectivityAnn)+$(deriveTextShow ''SourceStrictness)+$(deriveTextShow ''SourceUnpackedness)+$(deriveTextShow ''TypeFamilyHead)+#else+$(deriveTextShow ''Strict) #endif
src/TextShow/System/Console/Haskeline.hs view
@@ -25,7 +25,7 @@ import System.Console.Haskeline.Completion (Completion) import System.Console.Haskeline.History (History, historyLines) -import TextShow (TextShow(showb, showbPrec), Builder, FromStringShow(..))+import TextShow (TextShow(..), Builder, FromStringShow(..)) import TextShow.TH (deriveTextShow) import TextShow.Utils (showbUnaryListWith)
src/TextShow/System/Console/Terminfo.hs view
@@ -29,7 +29,7 @@ import System.Console.Terminfo.Base (SetupTermError) import System.Console.Terminfo.Color (Color) -import TextShow (TextShow(showb, showbPrec), Builder, FromStringShow(..))+import TextShow (TextShow(..), Builder, FromStringShow(..)) import TextShow.TH (deriveTextShow) #include "inline.h"
src/TextShow/System/Directory.hs view
@@ -16,7 +16,7 @@ import System.Directory (Permissions) -import TextShow (TextShow(showbPrec), Builder)+import TextShow (TextShow(..), Builder) import TextShow.TH (deriveTextShow) -- | Convert 'Permissions' to a 'Builder' with the given precedence.
src/TextShow/System/Locale.hs view
@@ -16,7 +16,7 @@ import System.Locale (TimeLocale) -import TextShow (TextShow(showbPrec), Builder)+import TextShow (TextShow(..), Builder) import TextShow.TH (deriveTextShow) -- | Convert a 'TimeLocale' to a 'Builder' with the given precedence.
src/TextShow/System/Posix.hs view
@@ -33,7 +33,7 @@ import System.Posix.Process (ProcessStatus) import System.Posix.User (GroupEntry, UserEntry) -import TextShow (Builder, showb, showbPrec)+import TextShow (TextShow(..), Builder) import TextShow.TH (deriveTextShow) -- | Convert an 'RTLDFlags' value to a 'Builder'.
src/TextShow/System/Random.hs view
@@ -15,7 +15,7 @@ module TextShow.System.Random (showbStdGenPrec) where import System.Random (StdGen)-import TextShow (TextShow(showbPrec), Builder, FromStringShow(..))+import TextShow (TextShow(..), Builder, FromStringShow(..)) #include "inline.h"
src/TextShow/System/Time.hs view
@@ -25,7 +25,7 @@ import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day, calendarTimeToString, toCalendarTime) -import TextShow (TextShow(showb, showbPrec), Builder, fromString)+import TextShow (TextShow(..), Builder, fromString) import TextShow.TH (deriveTextShow) #include "inline.h"
src/TextShow/System/Win32.hs view
@@ -39,7 +39,7 @@ import System.Win32.Info (ProcessorArchitecture, SYSTEM_INFO) import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId) -import TextShow (Builder, showb, showbPrec)+import TextShow (TextShow(..), Builder) import TextShow.TH (deriveTextShow) -- | Convert a 'DebugEventInfo' value to a 'Builder' with the given precedence.
src/TextShow/Text/PrettyPrint.hs view
@@ -16,25 +16,42 @@ module TextShow.Text.PrettyPrint ( renderB , renderStyleB+#if MIN_VERSION_pretty(1,1,3)+ , renderAnnotB+ , renderStyleAnnotB+#endif , showbMode , showbStylePrec , showbTextDetailsPrec #if MIN_VERSION_pretty(1,1,2) , showbPrettyLevelPrec #endif+#if MIN_VERSION_pretty(1,1,3)+ , liftShowbAnnotDetailsPrec+ , showbPrettyLevelAnnotPrec+ , liftShowbSpanPrec+#endif ) where -import Data.Monoid.Compat+import Data.Monoid.Compat -import Text.PrettyPrint.HughesPJ (Doc, Mode, Style(..), TextDetails(..),- fullRender, style)+import Text.PrettyPrint.HughesPJ (Doc, Mode, Style(..), TextDetails(..),+ fullRender, style) #if MIN_VERSION_pretty(1,1,2)-import Text.PrettyPrint.HughesPJClass (PrettyLevel)+import Text.PrettyPrint.HughesPJClass (PrettyLevel) #endif+#if MIN_VERSION_pretty(1,1,3)+import qualified Text.PrettyPrint.Annotated.HughesPJ as Annot (Doc, fullRender, style)+import Text.PrettyPrint.Annotated.HughesPJ (AnnotDetails, Span)+import qualified Text.PrettyPrint.Annotated.HughesPJClass as Annot (PrettyLevel) -import TextShow (TextShow(showb, showbPrec), Builder, fromString, singleton)-import TextShow.TH (deriveTextShow)+import TextShow (TextShow1(..))+import TextShow.TH (deriveTextShow1)+#endif +import TextShow (TextShow(..), Builder, fromString, singleton)+import TextShow.TH (deriveTextShow)+ #include "inline.h" -- | Renders a 'Doc' to a 'Builder' using the default 'style'.@@ -93,6 +110,53 @@ {-# INLINE showbPrettyLevelPrec #-} #endif +#if MIN_VERSION_pretty(1,1,3)+-- | Renders an annotated 'Doc' to a 'Builder' using the default 'Annot.style'.+-- This function is only available with @pretty-1.1.3@ or later.+--+-- /Since: 3/+renderAnnotB :: Annot.Doc a -> Builder+renderAnnotB = renderStyleAnnotB Annot.style+{-# INLINE renderAnnotB #-}++-- | Renders an annotated 'Doc' to a 'Builder' using the given 'Style'.+-- This function is only available with @pretty-1.1.3@ or later.+--+-- /Since: 3/+renderStyleAnnotB :: Style -> Annot.Doc a -> Builder+renderStyleAnnotB sty doc =+ Annot.fullRender (mode sty)+ (lineLength sty)+ (ribbonsPerLine sty)+ txtPrinter+ mempty+ doc++-- | Convert an 'AnnotDetais' value to a 'Builder' with the given show function+-- and precedence. This function is only available with @pretty-1.1.3@ or later.+--+-- /Since: 3/+liftShowbAnnotDetailsPrec :: (Int -> a -> Builder) -> Int -> AnnotDetails a -> Builder+liftShowbAnnotDetailsPrec sp = liftShowbPrec sp undefined+{-# INLINE liftShowbAnnotDetailsPrec #-}++-- | Convert an annotated 'PrettyLevel' value to a 'Builder' with the given precedence.+-- This function is only available with @pretty-1.1.3@ or later.+--+-- /Since: 3/+showbPrettyLevelAnnotPrec :: Int -> Annot.PrettyLevel -> Builder+showbPrettyLevelAnnotPrec = showbPrec+{-# INLINE showbPrettyLevelAnnotPrec #-}++-- | Convert a 'Span' to a 'Builder' with the given show function and precedence.+-- This function is only available with @pretty-1.1.3@ or later.+--+-- /Since: 3/+liftShowbSpanPrec :: (Int -> a -> Builder) -> Int -> Span a -> Builder+liftShowbSpanPrec sp = liftShowbPrec sp undefined+{-# INLINE liftShowbSpanPrec #-}+#endif+ instance TextShow Doc where showb = renderB INLINE_INST_FUN(showb)@@ -103,4 +167,21 @@ #if MIN_VERSION_pretty(1,1,2) $(deriveTextShow ''PrettyLevel)+#endif++#if MIN_VERSION_pretty(1,1,3)+$(deriveTextShow ''AnnotDetails)+$(deriveTextShow1 ''AnnotDetails)++instance TextShow (Annot.Doc a) where+ showb = renderAnnotB+ INLINE_INST_FUN(showb)+instance TextShow1 Annot.Doc where+ liftShowbPrec _ _ = showbPrec+ INLINE_INST_FUN(liftShowbPrec)++$(deriveTextShow ''Annot.PrettyLevel)++$(deriveTextShow ''Span)+$(deriveTextShow1 ''Span) #endif
src/TextShow/Trace/Hpc.hs view
@@ -25,7 +25,7 @@ import Data.Monoid.Compat -import TextShow (TextShow(showb, showbPrec), Builder, FromStringShow(..), singleton)+import TextShow (TextShow(..), Builder, FromStringShow(..), singleton) import TextShow.Data.Integral (showbIntPrec) import TextShow.Data.Time () import TextShow.TH (deriveTextShow)
src/TextShow/Utils.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-|@@ -11,40 +10,11 @@ Miscellaneous utility functions. -}-module TextShow.Utils (- mtimesDefault- , showbUnaryListWith- , showbUnaryList- ) where--#if MIN_VERSION_semigroups(0,17,0)-import Data.Semigroup (mtimesDefault)-#else-import Data.Semigroup (timesN)-#endif--import TextShow (TextShow(showbPrec), Builder, showbUnaryWith)-import TextShow.Data.List (showbListWith)+module TextShow.Utils (showbUnaryListWith) where -#if !(MIN_VERSION_semigroups(0,17,0))--- | Repeat a value @n@ times.------ > mtimesDefault n a = a <> a <> ... <> a -- using <> (n-1) times-mtimesDefault :: (Integral b, Monoid a) => b -> a -> a-mtimesDefault = timesN . fromIntegral-{-# INLINE mtimesDefault #-}-#endif+import TextShow (Builder, showbUnaryWith) -- | This pattern is used frequently when showing container types.-showbUnaryListWith :: (a -> Builder) -> Int -> [a] -> Builder-showbUnaryListWith sp p = showbUnaryWith (const $ showbListWith sp) "fromList" p+showbUnaryListWith :: ([a] -> Builder) -> Int -> [a] -> Builder+showbUnaryListWith sl p = showbUnaryWith (const sl) "fromList" p {-# INLINE showbUnaryListWith #-}---- | This pattern is used frequently when showing container types.------ We define this separately from 'showbUnaryListWith' since calling 'showbPrec' on--- a list may result in different output than 'showbListWith' (since a 'Show'--- instance may override 'showbList').-showbUnaryList :: TextShow a => Int -> [a] -> Builder-showbUnaryList p = showbUnaryWith showbPrec "fromList" p-{-# INLINE showbUnaryList #-}
tests/Instances/Data/Bifunctor.hs view
@@ -18,6 +18,7 @@ import Data.Bifunctor.Biff (Biff(..)) import Data.Bifunctor.Clown (Clown(..))+import Data.Bifunctor.Fix (Fix(..)) import Data.Bifunctor.Flip (Flip(..)) import Data.Bifunctor.Join (Join(..)) import Data.Bifunctor.Joker (Joker(..))@@ -32,6 +33,7 @@ deriving instance Arbitrary (p (f a) (g b)) => Arbitrary (Biff p f g a b) deriving instance Arbitrary (f a) => Arbitrary (Clown f a b)+deriving instance Arbitrary (p (Fix p a) a) => Arbitrary (Fix p a) deriving instance Arbitrary (p b a) => Arbitrary (Flip p a b) deriving instance Arbitrary (p a a) => Arbitrary (Join p a) deriving instance Arbitrary (g b) => Arbitrary (Joker g a b)
− tests/Instances/Data/List/NonEmpty.hs
@@ -1,22 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-|-Module: Instances.Data.List.NonEmpty-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--Provides an 'Arbitrary' instance for 'NonEmpty' lists.--}-module Instances.Data.List.NonEmpty () where--import Data.List.NonEmpty (NonEmpty(..))--import Prelude ()-import Prelude.Compat--import Test.QuickCheck (Arbitrary(..))--instance Arbitrary a => Arbitrary (NonEmpty a) where- arbitrary = (:|) <$> arbitrary <*> arbitrary
− tests/Instances/Data/Semigroup.hs
@@ -1,32 +0,0 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE StandaloneDeriving #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-|-Module: Instances.Data.Semigroup-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--Provides 'Arbitrary' instances for @Semigroup@ data types.--}-module Instances.Data.Semigroup () where--import Data.Semigroup (Min(..), Max(..), First(..), Last(..),- WrappedMonoid(..), Option(..), Arg(..))--import Prelude ()-import Prelude.Compat--import Test.QuickCheck (Arbitrary(..))--deriving instance Arbitrary a => Arbitrary (Min a)-deriving instance Arbitrary a => Arbitrary (Max a)-deriving instance Arbitrary a => Arbitrary (First a)-deriving instance Arbitrary a => Arbitrary (Last a)-deriving instance Arbitrary m => Arbitrary (WrappedMonoid m)-deriving instance Arbitrary a => Arbitrary (Option a)--instance (Arbitrary a, Arbitrary b) => Arbitrary (Arg a b) where- arbitrary = Arg <$> arbitrary <*> arbitrary
tests/Instances/Language/Haskell/TH.hs view
@@ -50,10 +50,14 @@ -- arbitrary = Clause <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary Con where- arbitrary = oneof [ NormalC <$> arbitrary <*> arbitrary- , RecC <$> arbitrary <*> arbitrary- , InfixC <$> arbitrary <*> arbitrary <*> arbitrary- , ForallC <$> arbitrary <@> [fPred] <@> fCon+ arbitrary = oneof [ NormalC <$> arbitrary <*> arbitrary+ , RecC <$> arbitrary <*> arbitrary+ , InfixC <$> arbitrary <*> arbitrary <*> arbitrary+ , ForallC <$> arbitrary <@> [fPred] <@> fCon+#if MIN_VERSION_template_haskell(2,11,0)+ , GadtC <$> arbitrary <*> arbitrary <*> arbitrary+ , RecGadtC <$> arbitrary <*> arbitrary <*> arbitrary+#endif ] -- arbitrary = oneof [ NormalC <$> arbitrary <*> arbitrary -- , RecC <$> arbitrary <*> arbitrary@@ -65,22 +69,50 @@ arbitrary = oneof [ FunD <$> arbitrary <@> [fClause] , pure $ ValD fPat fBody [fDec]- , DataD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary- , NewtypeD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , DataD [fPred] <$> arbitrary+ <*> arbitrary+#if MIN_VERSION_template_haskell(2,11,0)+ <*> arbitrary+#endif+ <*> arbitrary+ <*> arbitrary+ , NewtypeD [fPred] <$> arbitrary+ <*> arbitrary+#if MIN_VERSION_template_haskell(2,11,0)+ <*> arbitrary+#endif+ <*> arbitrary+ <*> arbitrary , TySynD <$> arbitrary <*> arbitrary <*> arbitrary , ClassD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <@> [fDec] , InstanceD [fPred] <$> arbitrary <@> [fDec] , SigD <$> arbitrary <*> arbitrary , ForeignD <$> arbitrary , PragmaD <$> arbitrary- , FamilyD <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary- , DataInstD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary- , NewtypeInstD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , DataInstD [fPred] <$> arbitrary+ <*> arbitrary+#if MIN_VERSION_template_haskell(2,11,0)+ <*> arbitrary+#endif+ <*> arbitrary+ <*> arbitrary+ , NewtypeInstD [fPred] <$> arbitrary+ <*> arbitrary+#if MIN_VERSION_template_haskell(2,11,0)+ <*> arbitrary+#endif+ <*> arbitrary+ <*> arbitrary #if MIN_VERSION_template_haskell(2,8,0) , InfixD <$> arbitrary <*> arbitrary #endif #if MIN_VERSION_template_haskell(2,9,0)- , ClosedTypeFamilyD <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , ClosedTypeFamilyD <$> arbitrary+ <*> arbitrary+# if !(MIN_VERSION_template_haskell(2,11,0))+ <*> arbitrary+ <*> arbitrary+# endif , RoleAnnotD <$> arbitrary <*> arbitrary , TySynInstD <$> arbitrary <*> arbitrary #else@@ -90,6 +122,12 @@ , StandaloneDerivD <$> arbitrary <*> arbitrary , DefaultSigD <$> arbitrary <*> arbitrary #endif+#if MIN_VERSION_template_haskell(2,11,0)+ , DataFamilyD <$> arbitrary <*> arbitrary <*> arbitrary+ , OpenTypeFamilyD <$> arbitrary+#else+ , FamilyD <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+#endif ] -- arbitrary = oneof [ -- FunD <$> arbitrary <*> arbitrary@@ -158,6 +196,9 @@ #if MIN_VERSION_template_haskell(2,10,0) , pure $ StaticE fExp #endif+#if MIN_VERSION_template_haskell(2,11,0)+ , UnboundVarE <$> arbitrary+#endif ] -- arbitrary = oneof [ VarE <$> arbitrary -- , ConE <$> arbitrary@@ -229,11 +270,26 @@ #else pure $ ClassI fDec #endif- , ClassOpI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , ClassOpI <$> arbitrary+ <*> arbitrary+ <*> arbitrary+#if !(MIN_VERSION_template_haskell(2,11,0))+ <*> arbitrary+#endif , pure $ TyConI fDec , PrimTyConI <$> arbitrary <*> arbitrary <*> arbitrary- , DataConI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary- , VarI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , DataConI <$> arbitrary+ <*> arbitrary+ <*> arbitrary+#if !(MIN_VERSION_template_haskell(2,11,0))+ <*> arbitrary+#endif+ , VarI <$> arbitrary+ <*> arbitrary+ <*> arbitrary+#if !(MIN_VERSION_template_haskell(2,11,0))+ <*> arbitrary+#endif , TyVarI <$> arbitrary <*> arbitrary #if MIN_VERSION_template_haskell(2,7,0) , pure $ FamilyI fDec [fDec]@@ -268,6 +324,9 @@ #if MIN_VERSION_template_haskell(2,5,0) , StringPrimL <$> arbitrary #endif+#if MIN_VERSION_template_haskell(2,11,0)+ , CharPrimL <$> arbitrary+#endif ] instance Arbitrary Loc where@@ -403,11 +462,6 @@ -- , ParS <$> arbitrary -- ] -deriving instance Bounded Strict-deriving instance Enum Strict-instance Arbitrary Strict where- arbitrary = arbitraryBoundedEnum- instance Arbitrary Type where arbitrary = oneof [ pure $ ForallT [fTyVarBndr] [fPred] fType , VarT <$> arbitrary@@ -432,6 +486,12 @@ #if MIN_VERSION_template_haskell(2,10,0) , pure EqualityT #endif+#if MIN_VERSION_template_haskell(2,11,0)+ , InfixT fType <$> arbitrary <@> fType+ , UInfixT fType <$> arbitrary <@> fType+ , pure $ ParensT fType+ , pure WildCardT+#endif ] -- arbitrary = oneof [ ForallT <$> arbitrary <*> arbitrary <*> arbitrary -- , VarT <$> arbitrary@@ -511,7 +571,7 @@ instance Arbitrary Module where arbitrary = Module <$> arbitrary <*> arbitrary- + instance Arbitrary ModuleInfo where arbitrary = ModuleInfo <$> arbitrary @@ -535,6 +595,46 @@ -- arbitrary = oneof [ ClassP <$> arbitrary <*> arbitrary -- , EqualP <$> arbitrary <*> arbitrary -- ]+#endif++#if MIN_VERSION_template_haskell(2,11,0)+instance Arbitrary Bang where+ arbitrary = Bang <$> arbitrary <*> arbitrary++deriving instance Bounded DecidedStrictness+deriving instance Enum DecidedStrictness+instance Arbitrary DecidedStrictness where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary FamilyResultSig where+ arbitrary = oneof [ pure NoSig+ , pure $ KindSig fKind+ , pure $ TyVarSig fTyVarBndr+ ]++instance Arbitrary InjectivityAnn where+ arbitrary = pure $ InjectivityAnn fName [fName]++deriving instance Bounded SourceStrictness+deriving instance Enum SourceStrictness+instance Arbitrary SourceStrictness where+ arbitrary = arbitraryBoundedEnum++deriving instance Bounded SourceUnpackedness+deriving instance Enum SourceUnpackedness+instance Arbitrary SourceUnpackedness where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary TypeFamilyHead where+ arbitrary = TypeFamilyHead fName+ [fTyVarBndr]+ <$> arbitrary+ <*> arbitrary+#else+deriving instance Bounded Strict+deriving instance Enum Strict+instance Arbitrary Strict where+ arbitrary = arbitraryBoundedEnum #endif deriving instance Arbitrary ModName
tests/Instances/Text/PrettyPrint.hs view
@@ -15,15 +15,21 @@ -} module Instances.Text.PrettyPrint () where -import Prelude ()-import Prelude.Compat+import Prelude ()+import Prelude.Compat -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)+import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) -import Text.PrettyPrint.HughesPJ (Doc, Mode(..), Style(..), TextDetails(..), text)+import Text.PrettyPrint.HughesPJ (Doc, Mode(..), Style(..),+ TextDetails(..), text) #if MIN_VERSION_pretty(1,1,2)-import Text.PrettyPrint.HughesPJClass (PrettyLevel(..))+import Text.PrettyPrint.HughesPJClass (PrettyLevel(..)) #endif+#if MIN_VERSION_pretty(1,1,3)+import qualified Text.PrettyPrint.Annotated.HughesPJ as Annot (Doc, text)+import Text.PrettyPrint.Annotated.HughesPJ (AnnotDetails(..), Span(..))+import qualified Text.PrettyPrint.Annotated.HughesPJClass as Annot (PrettyLevel(..))+#endif instance Arbitrary Doc where arbitrary = text <$> arbitrary@@ -45,4 +51,20 @@ deriving instance Show Mode deriving instance Show Style deriving instance Show TextDetails+#endif++#if MIN_VERSION_pretty(1,1,3)+instance Arbitrary a => Arbitrary (AnnotDetails a) where+ arbitrary = oneof [ pure AnnotStart+ , NoAnnot <$> arbitrary <*> arbitrary+ , AnnotEnd <$> arbitrary+ ]++instance Arbitrary (Annot.Doc a) where+ arbitrary = Annot.text <$> arbitrary++deriving instance Arbitrary Annot.PrettyLevel++instance Arbitrary a => Arbitrary (Span a) where+ arbitrary = Span <$> arbitrary <*> arbitrary <*> arbitrary #endif
tests/Spec/Data/BifunctorSpec.hs view
@@ -12,6 +12,7 @@ import Data.Bifunctor.Biff (Biff) import Data.Bifunctor.Clown (Clown)+import Data.Bifunctor.Fix (Fix) import Data.Bifunctor.Flip (Flip) import Data.Bifunctor.Join (Join) import Data.Bifunctor.Joker (Joker)@@ -37,6 +38,8 @@ prop "TextShow instance" (prop_matchesTextShow :: Int -> Biff Either [] Maybe Char Int -> Bool) describe "Clown [] Char Int" $ prop "TextShow instance" (prop_matchesTextShow :: Int -> Clown [] Char Int -> Bool)+ describe "Fix Either Int" $+ prop "TextShow instance" (prop_matchesTextShow :: Int -> Fix Either Int -> Bool) describe "Flip Either Int Char" $ prop "TextShow instance" (prop_matchesTextShow :: Int -> Flip Either Int Char -> Bool) describe "Join Either Int" $
− tests/Spec/Data/List/NonEmptySpec.hs
@@ -1,31 +0,0 @@-{-|-Module: Spec.Data.List.NonEmptySpec-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--@hspec@ tests for 'NonEmpty' lists.--}-module Spec.Data.List.NonEmptySpec (main, spec) where--import Data.List.NonEmpty (NonEmpty)--import Instances.Data.List.NonEmpty ()--import Spec.Utils (prop_matchesTextShow, prop_genericTextShow, prop_genericTextShow1)--import Test.Hspec (Spec, describe, hspec, parallel)-import Test.Hspec.QuickCheck (prop)--import TextShow.Data.List.NonEmpty ()--main :: IO ()-main = hspec spec--spec :: Spec-spec = parallel . describe "NonEmpty Char" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> NonEmpty Char -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> NonEmpty Char -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> NonEmpty Char -> Bool)
− tests/Spec/Data/SemigroupSpec.hs
@@ -1,56 +0,0 @@-{-|-Module: Spec.Data.SemigroupSpec-Copyright: (C) 2014-2015 Ryan Scott-License: BSD-style (see the file LICENSE)-Maintainer: Ryan Scott-Stability: Provisional-Portability: GHC--@hspec@ tests for @Semigroup@ data types.--}-module Spec.Data.SemigroupSpec (main, spec) where--import Data.Semigroup (Min, Max, First, Last, WrappedMonoid, Option, Arg)--import Instances.Data.Semigroup ()--import Spec.Utils (prop_matchesTextShow, prop_genericTextShow, prop_genericTextShow1)--import Test.Hspec (Spec, describe, hspec, parallel)-import Test.Hspec.QuickCheck (prop)--import TextShow.Data.Semigroup ()--main :: IO ()-main = hspec spec--spec :: Spec-spec = parallel $ do- describe "Min Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> Min Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> Min Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> Min Int -> Bool)- describe "Max Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> Max Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> Max Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> Max Int -> Bool)- describe "First Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> First Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> First Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> First Int -> Bool)- describe "Last Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> Last Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> Last Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> Last Int -> Bool)- describe "WrappedMonoid Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> WrappedMonoid Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> WrappedMonoid Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> WrappedMonoid Int -> Bool)- describe "Option Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> Option Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> Option Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> Option Int -> Bool)- describe "Arg Int Int" $ do- prop "TextShow instance" (prop_matchesTextShow :: Int -> Arg Int Int -> Bool)- prop "generic TextShow" (prop_genericTextShow :: Int -> Arg Int Int -> Bool)- prop "generic TextShow1" (prop_genericTextShow1 :: Int -> Arg Int Int -> Bool)
tests/Spec/Language/Haskell/THSpec.hs view
@@ -38,6 +38,11 @@ prop "TextShow instance" (prop_matchesTextShow :: Int -> AnnTarget -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> AnnTarget -> Bool) #endif+#if MIN_VERSION_template_haskell(2,11,0)+ describe "Bang" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> Bang -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> Bang -> Bool)+#endif describe "Body" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Body -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Body -> Bool)@@ -58,6 +63,11 @@ describe "Dec" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Dec -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Dec -> Bool)+#if MIN_VERSION_template_haskell(2,11,0)+ describe "DecidedStrictness" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> DecidedStrictness -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> DecidedStrictness -> Bool)+#endif describe "Doc" $ prop "TextShow instance" (prop_matchesTextShow :: Int -> Doc -> Bool) describe "Exp" $ do@@ -66,6 +76,11 @@ describe "FamFlavour" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> FamFlavour -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> FamFlavour -> Bool)+#if MIN_VERSION_template_haskell(2,11,0)+ describe "FamilyResultSig" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> FamilyResultSig -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> FamilyResultSig -> Bool)+#endif describe "Fixity" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Fixity -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Fixity -> Bool)@@ -84,6 +99,11 @@ describe "Info" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Info -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Info -> Bool)+#if MIN_VERSION_template_haskell(2,11,0)+ describe "InjectivityAnn" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> InjectivityAnn -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> InjectivityAnn -> Bool)+#endif #if MIN_VERSION_template_haskell(2,8,0) describe "Inline" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Inline -> Bool)@@ -159,6 +179,14 @@ describe "Safety" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Safety -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Safety -> Bool)+#if MIN_VERSION_template_haskell(2,11,0)+ describe "SourceStrictness" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> SourceStrictness -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> SourceStrictness -> Bool)+ describe "SourceUnpackedness" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> SourceUnpackedness -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> SourceUnpackedness -> Bool)+#endif describe "Stmt" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Stmt -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Stmt -> Bool)@@ -173,6 +201,11 @@ describe "Type" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> Type -> Bool) prop "generic TextShow" (prop_genericTextShow :: Int -> Type -> Bool)+#if MIN_VERSION_template_haskell(2,11,0)+ describe "TypeFamilyHead" $ do+ prop "TextShow instance" (prop_matchesTextShow :: Int -> TypeFamilyHead -> Bool)+ prop "generic TextShow" (prop_genericTextShow :: Int -> TypeFamilyHead -> Bool)+#endif #if MIN_VERSION_template_haskell(2,9,0) describe "TySynEqn" $ do prop "TextShow instance" (prop_matchesTextShow :: Int -> TySynEqn -> Bool)
tests/Spec/Text/PrettyPrintSpec.hs view
@@ -11,22 +11,27 @@ -} module Spec.Text.PrettyPrintSpec (main, spec) where -import Instances.Text.PrettyPrint ()+import Instances.Text.PrettyPrint () -import Spec.Utils (prop_matchesTextShow)+import Spec.Utils (prop_matchesTextShow) #if MIN_VERSION_pretty(1,1,2)-import Spec.Utils (prop_genericTextShow)+import Spec.Utils (prop_genericTextShow) #endif -import Test.Hspec (Spec, describe, hspec, parallel)-import Test.Hspec.QuickCheck (prop)+import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop) -import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails {-, renderStyle -})+import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails {-, renderStyle -}) #if MIN_VERSION_pretty(1,1,2)-import Text.PrettyPrint.HughesPJClass (PrettyLevel)+import Text.PrettyPrint.HughesPJClass (PrettyLevel) #endif--- import TextShow (fromString)-import TextShow.Text.PrettyPrint () -- (renderStyleB)+#if MIN_VERSION_pretty(1,1,3)+import qualified Text.PrettyPrint.Annotated.HughesPJ as Annot (Doc)+import Text.PrettyPrint.Annotated.HughesPJ (AnnotDetails, Span)+import qualified Text.PrettyPrint.Annotated.HughesPJClass as Annot (PrettyLevel)+#endif+-- import TextShow (fromString)+import TextShow.Text.PrettyPrint () -- (renderStyleB) main :: IO () main = hspec spec@@ -56,6 +61,16 @@ #if MIN_VERSION_pretty(1,1,2) describe "PrettyLevel" $ prop "TextShow instance" (prop_matchesTextShow :: Int -> PrettyLevel -> Bool)+#endif+#if MIN_VERSION_pretty(1,1,3)+ describe "AnnotDetails Int" $+ prop "TextShow instance" (prop_matchesTextShow :: Int -> AnnotDetails Int -> Bool)+ describe "Doc Int (annotated)" $+ prop "TextShow instance" (prop_matchesTextShow :: Int -> Annot.Doc Int -> Bool)+ describe "PrettyLevel (annotated)" $+ prop "TextShow instance" (prop_matchesTextShow :: Int -> Annot.PrettyLevel -> Bool)+ describe "Span Int" $+ prop "TextShow instance" (prop_matchesTextShow :: Int -> Span Int -> Bool) #endif -- | Verifies that the output of 'renderStyle' and 'renderStyleB' coincides.
tests/Spec/Utils.hs view
@@ -9,58 +9,72 @@ Stability: Provisional Portability: GHC -@QuickCheck@ property-related utility functions.+Testing-related utility functions. -} module Spec.Utils (- prop_matchesTextShow+ ioProperty+ , prop_matchesTextShow+ , prop_matchesTextShow1+#if !(MIN_VERSION_transformers(0,4,0)) || MIN_VERSION_transformers(0,5,0)+ , prop_matchesTextShow2+#endif , prop_genericTextShow , prop_genericTextShow1 ) where -#if __GLASGOW_HASKELL__ >= 704-import GHC.Generics (Generic, Rep)-# if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1, Rep1)-# endif-import TextShow.Generic+import Data.Functor.Classes (Show1, showsPrec1)++import Generics.Deriving.Base++#if MIN_VERSION_QuickCheck(2,7,0)+import qualified Test.QuickCheck as QC (ioProperty)+#else+import Test.QuickCheck (morallyDubiousIOProperty) #endif+import Test.QuickCheck (Property, Testable) -import TextShow (TextShow(..), FromStringShow(..))-#if __GLASGOW_HASKELL__ >= 706-import TextShow (TextShow1(..), Builder)+import TextShow (TextShow(..), TextShow1(..), showbPrec1, fromString)+import TextShow.Generic++#if !(MIN_VERSION_transformers(0,4,0)) || MIN_VERSION_transformers(0,5,0)+import Data.Functor.Classes (Show2, showsPrec2)+import TextShow (TextShow2(..), showbPrec2) #endif +ioProperty :: Testable prop => IO prop -> Property+#if MIN_VERSION_QuickCheck(2,7,0)+ioProperty = QC.ioProperty+#else+ioProperty = morallyDubiousIOProperty+#endif+ -- | Verifies that a type's @Show@ instances coincide for both 'String's and 'Text', -- irrespective of precedence. prop_matchesTextShow :: (Show a, TextShow a) => Int -> a -> Bool-prop_matchesTextShow p x = showbPrec p (FromStringShow x) == showbPrec p x+prop_matchesTextShow p x = fromString (showsPrec p x "") == showbPrec p x +-- | Verifies that a type's @Show1@ instances coincide for both 'String's and 'Text',+-- irrespective of precedence.+prop_matchesTextShow1 :: (Show1 f, Show a, TextShow1 f, TextShow a) => Int -> f a -> Bool+prop_matchesTextShow1 p x = fromString (showsPrec1 p x "") == showbPrec1 p x++#if !(MIN_VERSION_transformers(0,4,0)) || MIN_VERSION_transformers(0,5,0)+-- | Verifies that a type's @Show2@ instances coincide for both 'String's and 'Text',+-- irrespective of precedence.+prop_matchesTextShow2 :: (Show2 f, Show a, Show b, TextShow2 f, TextShow a, TextShow b)+ => Int -> f a b -> Bool+prop_matchesTextShow2 p x = fromString (showsPrec2 p x "") == showbPrec2 p x+#endif+ -- | Verifies that a type's 'TextShow' instance coincides with the output produced -- by the equivalent 'Generic' functions.-#if __GLASGOW_HASKELL__ >= 704 prop_genericTextShow :: (TextShow a, Generic a, GTextShow (Rep a)) => Int -> a -> Bool prop_genericTextShow p x = showbPrec p x == genericShowbPrec p x-#else-prop_genericTextShow :: Int -> a -> Bool-prop_genericTextShow _ _ = True-#endif -- | Verifies that a type's 'TextShow1' instance coincides with the output produced -- by the equivalent 'Generic1' functions.-#if __GLASGOW_HASKELL__ >= 706-prop_genericTextShow1 :: (TextShow1 f, Generic1 f, GTextShow1 (Rep1 f))+prop_genericTextShow1 :: (TextShow1 f, Generic1 f, GTextShow1 (Rep1 f), TextShow a) => Int -> f a -> Bool-prop_genericTextShow1 p x = showbPrecWith showb27Prec p x- == genericShowbPrecWith showb27Prec p x-#else-prop_genericTextShow1 :: Int -> f a -> Bool-prop_genericTextShow1 _ _ = True-#endif--#if __GLASGOW_HASKELL__ >= 706--- | Show the number 27, which certain parody singer-songwriters find humorous.--- Useful for testing higher-order 'TextShow' classes.-showb27Prec :: Int -> a -> Builder-showb27Prec p _ = showbPrec p $ Just (27 :: Int)-#endif+prop_genericTextShow1 p x =+ showbPrec1 p x == genericLiftShowbPrec showbPrec showbList p x
text-show-instances.cabal view
@@ -1,5 +1,5 @@ name: text-show-instances-version: 2.1+version: 3 synopsis: Additional instances for text-show description: @text-show-instances@ is a supplemental library to @text-show@ that provides additional @Show@ instances for data types in@@ -60,7 +60,7 @@ license: BSD3 license-file: LICENSE author: Ryan Scott-maintainer: Ryan Scott <ryan.gl.scott@ku.edu>+maintainer: Ryan Scott <ryan.gl.scott@gmail.com> stability: Experimental copyright: (C) 2014-2015 Ryan Scott category: Text@@ -70,7 +70,8 @@ , GHC == 7.4.2 , GHC == 7.6.3 , GHC == 7.8.4- , GHC == 7.10.1+ , GHC == 7.10.3+ , GHC == 8.0.1 extra-source-files: CHANGELOG.md, README.md, include/inline.h cabal-version: >=1.10 @@ -78,6 +79,11 @@ type: git location: https://github.com/RyanGlScott/text-show-instances +flag developer+ description: Operate in developer mode (allows for faster recompilation of tests)+ default: False+ manual: True+ library exposed-modules: TextShow.Instances @@ -88,8 +94,6 @@ TextShow.Data.Binary TextShow.Data.Containers TextShow.Data.Functor.Trans- TextShow.Data.List.NonEmpty- TextShow.Data.Semigroup TextShow.Data.Tagged TextShow.Data.Time TextShow.Data.UnorderedContainers@@ -113,8 +117,8 @@ other-modules: TextShow.Utils build-depends: base >= 4.3 && < 5 , base-compat >= 0.8.1 && < 1- , bifunctors >= 5 && < 6- , binary >= 0.6 && < 0.8+ , bifunctors >= 5.1 && < 6+ , binary >= 0.6 && < 0.9 , bytestring >= 0.9 && < 0.11 , containers >= 0.1 && < 0.6 , directory >= 1 && < 1.3@@ -129,10 +133,10 @@ , tagged >= 0.4.4 && < 1 , template-haskell >= 2.5 && < 2.12 , text >= 0.11.1 && < 1.3- , text-show >= 2 && < 2.2- , time >= 0.1 && < 1.6- , transformers >= 0.2.1 && < 0.5- , transformers-compat >= 0.3 && < 1+ , text-show >= 3 && < 4+ , time >= 0.1 && < 1.7+ , transformers >= 0.2.1 && < 0.6+ , transformers-compat >= 0.5 && < 1 , unordered-containers >= 0.2 && < 0.3 , vector >= 0.9 && < 0.12 , xhtml >= 3000.2 && < 3000.3@@ -159,8 +163,6 @@ Instances.Data.Binary Instances.Data.Containers Instances.Data.Functor.Trans- Instances.Data.List.NonEmpty- Instances.Data.Semigroup Instances.Data.Tagged Instances.Language.Haskell.TH Instances.Miscellaneous@@ -187,8 +189,6 @@ Spec.Data.BinarySpec Spec.Data.ContainersSpec Spec.Data.Functor.TransSpec- Spec.Data.List.NonEmptySpec- Spec.Data.SemigroupSpec Spec.Data.TaggedSpec Spec.Data.TimeSpec Spec.Data.UnorderedContainersSpec@@ -211,11 +211,12 @@ Spec.System.PosixSpec build-depends: base >= 4.3 && < 5 , base-compat >= 0.8.1 && < 1- , bifunctors >= 5 && < 6- , binary >= 0.6 && < 0.8+ , bifunctors >= 5.1 && < 6+ , binary >= 0.6 && < 0.9 , bytestring >= 0.9 && < 0.11 , containers >= 0.1 && < 0.6 , directory >= 1 && < 1.3+ , generic-deriving >= 1.9 && < 2 , ghc-prim , haskeline >= 0.7 && < 0.8 , hoopl >= 3.8.7 && < 3.11@@ -227,21 +228,30 @@ , QuickCheck >= 2.5 && < 3 , quickcheck-instances >= 0.1 && < 0.4 , random >= 1.0.1 && < 1.2- , semigroups >= 0.8.4 && < 1+ , semigroups >= 0.17 && < 1 , tagged >= 0.4.4 && < 1 , template-haskell >= 2.5 && < 2.12- , text-show >= 2 && < 2.2- , text-show-instances == 2.1+ , text >= 0.11.1 && < 1.3+ , text-show >= 3 && < 4 , th-orphans >= 0.12 && < 1- , time >= 0.1 && < 1.6- , transformers >= 0.2.1 && < 0.5- , transformers-compat >= 0.3 && < 1+ , time >= 0.1 && < 1.7+ , transformers >= 0.2.1 && < 0.6+ , transformers-compat >= 0.5 && < 1 , unordered-containers >= 0.2 && < 0.3 , vector >= 0.9 && < 0.12 , xhtml >= 3000.2 && < 3000.3+ if !flag(developer)+ build-depends: text-show-instances == 3+ hs-source-dirs: tests+ if flag(developer)+ hs-source-dirs: src+ default-language: Haskell2010 ghc-options: -Wall -threaded -rtsopts+ include-dirs: include+ includes: inline.h+ install-includes: inline.h if os(windows) build-depends: Win32 >= 2.1 && < 2.4