packages feed

text-show 2.1.1 → 2.1.2

raw patch · 27 files changed

+685/−203 lines, 27 filesdep ~basedep ~bifunctorsdep ~generic-deriving

Dependency ranges changed: base, bifunctors, generic-deriving, template-haskell, text-show, transformers

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# 2.1.2+* Fixed GHC 7.10.3 build+* Extended `TextShow.Generic` to allow `genericShowbPrec` (and friends) to be used on `Generic` datatypes with `Char#`, `Double#`, `Float#`, `Int#`, and `Word#` argument types, just like string `Show` does+* Added `Generic1` instances for `FromStringShow` and `FromTextShow`+* Added `TextShow` instances for `UChar`, `UDouble`, `UFloat`, `UInt`, and `UWord` in `TextShow.GHC.Generics`+ # 2.1.1 * Restore support for `semigroups-0.16.1` @@ -36,7 +42,7 @@  * `genericShowList` → `genericShowtList`  * `genericShowListLazy` → `genericShowtlList`  * `genericPrint` → `genericPrintT`- * `genericPrintLazy` → genericPrintTL``+ * `genericPrintLazy` → `genericPrintTL`  * `genericHPrint` → `genericHPrintT`  * `genericHPrintLazy` → `genericHPrintTL`  * `deriveShow` → `deriveTextShow`
README.md view
@@ -32,4 +32,4 @@  If you desire it, there are also monomorphic versions of the `showb` function available in the submodules of `Text.Show.Text`. See the [naming conventions](https://github.com/RyanGlScott/text-show/wiki/Naming-conventions) page for more information. -Support for automatically deriving `TextShow` instances can be found in the `TextShow.TH` and `TextShow.Generic` modules. If you don't know which one to use, use `TextShow.TH`.+Support for automatically deriving `TextShow` instances can be found in the `TextShow.TH` and `TextShow.Generic` modules.
src/TextShow/Control/Exception.hs view
@@ -45,7 +45,7 @@  import Data.Monoid.Compat ((<>)) import Data.Text.Lazy.Builder (Builder, fromString)-#if MIN_VERSION_base(4,8,2)+#if MIN_VERSION_base(4,9,0) import Data.Text.Lazy.Builder (singleton) #endif @@ -210,13 +210,10 @@ -- -- /Since: 2/ showbErrorCall :: ErrorCall -> Builder-#if MIN_VERSION_base(4,8,2)-showbErrorCall (ErrorCallWithLocation err "")  = fromString err+showbErrorCall (ErrorCall err) = fromString err+#if MIN_VERSION_base(4,9,0) showbErrorCall (ErrorCallWithLocation err loc) =   fromString err <> singleton '\n' <> fromString loc-#else-showbErrorCall (ErrorCall err) = fromString err-{-# INLINE showbErrorCall #-} #endif  -- | Convert a 'MaskingState' to a 'Builder'.
src/TextShow/Data/Typeable.hs view
@@ -19,10 +19,15 @@ import Data.Text.Lazy.Builder (Builder, fromString, singleton) import Data.Typeable (TypeRep, typeRepArgs, typeRepTyCon) #if MIN_VERSION_base(4,4,0)-import Data.Typeable.Internal (TyCon(..), funTc, listTc)+import Data.Typeable.Internal (TyCon, tyConName) # if MIN_VERSION_base(4,8,0) import Data.Typeable.Internal (typeRepKinds) # endif+# if MIN_VERSION_base(4,9,0)+import Data.Typeable.Internal (tcFun, tcList)+# elif MIN_VERSION_base(4,4,0)+import Data.Typeable.Internal (funTc, listTc)+# endif #else import Data.Typeable (TyCon, mkTyCon, tyConString, typeOf) #endif@@ -41,8 +46,8 @@ showbTypeRepPrec p tyrep =     case tys of       [] -> showbTyCon tycon-      [x]   | tycon == listTc -> singleton '[' <> showb x <> singleton ']'-      [a,r] | tycon == funTc  -> showbParen (p > 8) $+      [x]   | tycon == tcList -> singleton '[' <> showb x <> singleton ']'+      [a,r] | tycon == tcFun  -> showbParen (p > 8) $                                     showbPrec 9 a                                  <> " -> "                                  <> showbPrec 8 r@@ -65,12 +70,20 @@  #if !(MIN_VERSION_base(4,4,0)) -- | The list 'TyCon'.-listTc :: TyCon-listTc = typeRepTyCon $ typeOf [()]+tcList :: TyCon+tcList = typeRepTyCon $ typeOf [()]  -- | The function (@->@) 'TyCon'.-funTc :: TyCon-funTc = mkTyCon "->"+tcFun :: TyCon+tcFun = mkTyCon "->"+#elif !(MIN_VERSION_base(4,9,0))+-- | The list 'TyCon'.+tcList :: TyCon+tcList = listTc++-- | The function (@->@) 'TyCon'.+tcFun :: TyCon+tcFun = funTc #endif  -- | Does the 'TyCon' represent a tuple type constructor?
src/TextShow/FromStringTextShow.hs view
@@ -4,12 +4,11 @@ {-# LANGUAGE DeriveFunctor              #-} {-# LANGUAGE DeriveTraversable          #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TemplateHaskell            #-}+{-# LANGUAGE TypeFamilies               #-}  #if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric              #-}-#else-{-# LANGUAGE TemplateHaskell            #-}-{-# LANGUAGE TypeFamilies               #-} #endif  #if __GLASGOW_HASKELL__ >= 708@@ -32,13 +31,15 @@  import           Data.Data (Data, Typeable) +#if __GLASGOW_HASKELL__ < 706+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 702 import           GHC.Generics (Generic) # if __GLASGOW_HASKELL__ >= 706 import           GHC.Generics (Generic1) # endif-#else-import qualified Generics.Deriving.TH as Generics (deriveAll) #endif  import           Prelude ()@@ -137,7 +138,14 @@  ------------------------------------------------------------------------------- +#if __GLASGOW_HASKELL__ < 706+$(Generics.deriveMeta           ''FromStringShow)+$(Generics.deriveRepresentable1 ''FromStringShow)+$(Generics.deriveMeta           ''FromTextShow)+$(Generics.deriveRepresentable1 ''FromTextShow)+#endif+ #if __GLASGOW_HASKELL__ < 702-$(Generics.deriveAll ''FromStringShow)-$(Generics.deriveAll ''FromTextShow)+$(Generics.deriveRepresentable0 ''FromStringShow)+$(Generics.deriveRepresentable0 ''FromTextShow) #endif
src/TextShow/GHC/Generics.hs view
@@ -1,6 +1,10 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TemplateHaskell  #-}-{-# LANGUAGE TypeOperators    #-}+{-# LANGUAGE CPP                  #-}+{-# LANGUAGE FlexibleContexts     #-}+{-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE MagicHash            #-}+{-# LANGUAGE TemplateHaskell      #-}+{-# LANGUAGE TypeOperators        #-}+{-# LANGUAGE TypeSynonymInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-}  {-|@@ -32,19 +36,34 @@     , showbFixityPrec     , showbAssociativity     , showbArityPrec+    , showbUCharPrec+    , showbUDoublePrec+    , showbUFloatPrec+    , showbUIntPrec+    , showbUWordPrec     ) where  import Data.Text.Lazy.Builder (Builder) -import Generics.Deriving.Base (U1(..), Par1, Rec1(..), K1(..),-                               M1(..), (:+:)(..), (:*:)(..), (:.:)(..),-                               Fixity, Associativity, Arity)+import Generics.Deriving.Base  import TextShow.Classes (TextShow(showb, showbPrec), TextShow1(..), TextShow2(..))+import TextShow.Data.Char     ()+import TextShow.Data.Floating () import TextShow.Data.Integral () import TextShow.TH.Internal (deriveTextShow, deriveTextShow1, makeShowbPrec,                              makeShowbPrecWith, makeShowbPrecWith2) +#if !(MIN_VERSION_template_haskell(2,7,0))+import Data.Monoid.Compat ((<>))+import Data.Text.Lazy.Builder (fromString, singleton)++import GHC.Exts (Char(C#), Double(D#), Float(F#), Int(I#), Word(W#))+import GHC.Show (appPrec)++import TextShow.Classes (showbParen)+#endif+ -- | Convert a 'U1' value to a 'Builder'. -- -- /Since: 2/@@ -159,6 +178,41 @@ showbArityPrec = showbPrec {-# INLINE showbArityPrec #-} +-- | Convert a 'UChar' to a 'Builder' with the given precedence.+--+-- /Since: 2.2/+showbUCharPrec :: Int -> UChar p -> Builder+showbUCharPrec = showbPrec+{-# INLINE showbUCharPrec #-}++-- | Convert a 'UDouble' to a 'Builder' with the given precedence.+--+-- /Since: 2.2/+showbUDoublePrec :: Int -> UDouble p -> Builder+showbUDoublePrec = showbPrec+{-# INLINE showbUDoublePrec #-}++-- | Convert a 'UFloat' to a 'Builder' with the given precedence.+--+-- /Since: 2.2/+showbUFloatPrec :: Int -> UFloat p -> Builder+showbUFloatPrec = showbPrec+{-# INLINE showbUFloatPrec #-}++-- | Convert a 'UInt' to a 'Builder' with the given precedence.+--+-- /Since: 2.2/+showbUIntPrec :: Int -> UInt p -> Builder+showbUIntPrec = showbPrec+{-# INLINE showbUIntPrec #-}++-- | Convert a 'UWord' to a 'Builder' with the given precedence.+--+-- /Since: 2.2/+showbUWordPrec :: Int -> UWord p -> Builder+showbUWordPrec = showbPrec+{-# INLINE showbUWordPrec #-}+ instance TextShow (U1 p) where     showbPrec = showbPrecWith undefined $(deriveTextShow1 ''U1)@@ -193,6 +247,68 @@ instance TextShow (f (g p)) => TextShow ((f :.: g) p) where     showbPrec = $(makeShowbPrec ''(:.:)) $(deriveTextShow1 ''(:.:))++#if MIN_VERSION_template_haskell(2,7,0)+instance TextShow (UChar p) where+    showbPrec = $(makeShowbPrec 'UChar)+$(deriveTextShow1 'UChar)++instance TextShow (UDouble p) where+    showbPrec = $(makeShowbPrec 'UDouble)+$(deriveTextShow1 'UDouble)++instance TextShow (UFloat p) where+    showbPrec = $(makeShowbPrec 'UFloat)+$(deriveTextShow1 'UFloat)++instance TextShow (UInt p) where+    showbPrec = $(makeShowbPrec 'UInt)+$(deriveTextShow1 'UInt)++instance TextShow (UWord p) where+    showbPrec = $(makeShowbPrec 'UWord)+$(deriveTextShow1 'UWord)+#else+instance TextShow (UChar p) where+    showbPrec = showbPrecWith undefined+instance TextShow1 UChar where+    showbPrecWith _ p (UChar c) = showbParen (p > appPrec) $+           fromString "UChar "    <> singleton '{'+        <> fromString "uChar# = " <> showb (C# c)+        <> singleton '}'++instance TextShow (UDouble p) where+    showbPrec = showbPrecWith undefined+instance TextShow1 UDouble where+    showbPrecWith _ p (UDouble d) = showbParen (p > appPrec) $+           fromString "UDouble "    <> singleton '{'+        <> fromString "uDouble# = " <> showb (D# d)+        <> singleton '}'++instance TextShow (UFloat p) where+    showbPrec = showbPrecWith undefined+instance TextShow1 UFloat where+    showbPrecWith _ p (UFloat f) = showbParen (p > appPrec) $+           fromString "UFloat "    <> singleton '{'+        <> fromString "uFloat# = " <> showb (F# f)+        <> singleton '}'++instance TextShow (UInt p) where+    showbPrec = showbPrecWith undefined+instance TextShow1 UInt where+    showbPrecWith _ p (UInt i) = showbParen (p > appPrec) $+           fromString "UInt "    <> singleton '{'+        <> fromString "uInt# = " <> showb (I# i)+        <> singleton '}'++instance TextShow (UWord p) where+    showbPrec = showbPrecWith undefined+instance TextShow1 UWord where+    showbPrecWith _ p (UWord w) = showbParen (p > appPrec) $+           fromString "UWord "    <> singleton '{'+        <> fromString "uWord# = " <> showb (W# w)+        <> singleton '}'+#endif  $(deriveTextShow ''Fixity) $(deriveTextShow ''Associativity)
src/TextShow/Generic.hs view
@@ -2,25 +2,23 @@ {-# LANGUAGE DeriveDataTypeable   #-} {-# LANGUAGE FlexibleContexts     #-} {-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE MagicHash            #-} {-# LANGUAGE OverloadedStrings    #-} {-# LANGUAGE ScopedTypeVariables  #-}+{-# LANGUAGE StandaloneDeriving   #-} {-# LANGUAGE TypeOperators        #-}--#if __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE DeriveGeneric        #-}-#else {-# LANGUAGE TemplateHaskell      #-} {-# LANGUAGE TypeFamilies         #-} {-# LANGUAGE TypeSynonymInstances #-}++#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE DeriveGeneric        #-} #endif  #if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds            #-} #endif -#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE StandaloneDeriving   #-}-#endif {-| Module:      TextShow.Generic Copyright:   (C) 2014-2015 Ryan Scott@@ -78,6 +76,8 @@ #if __GLASGOW_HASKELL__ < 702 import qualified Generics.Deriving.TH as Generics (deriveAll) #endif++import           GHC.Exts (Char(C#), Double(D#), Float(F#), Int(I#), Word(W#)) import           GHC.Show (appPrec, appPrec1)  import           Prelude ()@@ -296,6 +296,26 @@     -- If we have a product then it is not a nullary constructor     isNullary _ = False +instance GTextShow UChar where+    gShowbPrec _ = gShowbUCharPrec+    isNullary _ = False++instance GTextShow UDouble where+    gShowbPrec _ = gShowbUDoublePrec+    isNullary _ = False++instance GTextShow UFloat where+    gShowbPrec _ = gShowbUFloatPrec+    isNullary _ = False++instance GTextShow UInt where+    gShowbPrec _ = gShowbUIntPrec+    isNullary _ = False++instance GTextShow UWord where+    gShowbPrec _ = gShowbUWordPrec+    isNullary _ = False+ -------------------------------------------------------------------------------  -- | Class of generic representation types ('Rep1') that can be converted to@@ -353,6 +373,26 @@     gShowbPrecWith t sp n (Comp1 c) = showbPrecWith (gShowbPrecWith t sp) n c     isNullary1 _ = False +instance GTextShow1 UChar where+    gShowbPrecWith _ _ = gShowbUCharPrec+    isNullary1 _ = False++instance GTextShow1 UDouble where+    gShowbPrecWith _ _ = gShowbUDoublePrec+    isNullary1 _ = False++instance GTextShow1 UFloat where+    gShowbPrecWith _ _ = gShowbUFloatPrec+    isNullary1 _ = False++instance GTextShow1 UInt where+    gShowbPrecWith _ _ = gShowbUIntPrec+    isNullary1 _ = False++instance GTextShow1 UWord where+    gShowbPrecWith _ _ = gShowbUWordPrec+    isNullary1 _ = False+ ------------------------------------------------------------------------------- -- Shared code between GTextShow and GTextShow1 -------------------------------------------------------------------------------@@ -436,6 +476,33 @@        gsa t n a     <> showbSpace     <> gsb t n b++gShowbUCharPrec :: Int -> UChar p -> Builder+gShowbUCharPrec p (UChar c) = showbPrec (hashPrec p) (C# c) <> oneHash++gShowbUDoublePrec :: Int -> UDouble p -> Builder+gShowbUDoublePrec p (UDouble d) = showbPrec (hashPrec p) (D# d) <> twoHash++gShowbUFloatPrec :: Int -> UFloat p -> Builder+gShowbUFloatPrec p (UFloat f) = showbPrec (hashPrec p) (F# f) <> oneHash++gShowbUIntPrec :: Int -> UInt p -> Builder+gShowbUIntPrec p (UInt i) = showbPrec (hashPrec p) (I# i) <> oneHash++gShowbUWordPrec :: Int -> UWord p -> Builder+gShowbUWordPrec p (UWord w) = showbPrec (hashPrec p) (W# w) <> twoHash++oneHash, twoHash :: Builder+hashPrec :: Int -> Int+#if __GLASGOW_HASKELL__ >= 711+oneHash  = singleton '#'+twoHash  = fromString "##"+hashPrec = const 0+#else+oneHash  = mempty+twoHash  = mempty+hashPrec = id+#endif  ------------------------------------------------------------------------------- 
src/TextShow/TH/Internal.hs view
@@ -52,9 +52,8 @@ import           Data.List.Compat import qualified Data.List.NonEmpty as NE import           Data.List.NonEmpty (NonEmpty(..), (<|))-import qualified Data.Map as Map (fromList, lookup)+import qualified Data.Map as Map (fromList, findWithDefault) import           Data.Map (Map)-import           Data.Maybe (fromMaybe) import           Data.Monoid.Compat ((<>)) import qualified Data.Set as Set import           Data.Set (Set)@@ -1026,7 +1025,7 @@  subst :: Subst -> Type -> Type subst subs (ForallT v c t) = ForallT v c $ subst subs t-subst subs t@(VarT n)      = fromMaybe t $ Map.lookup n subs+subst subs t@(VarT n)      = Map.findWithDefault t n subs subst subs (AppT t1 t2)    = AppT (subst subs t1) (subst subs t2) subst subs (SigT t k)      = SigT (subst subs t) k subst _ t                  = t
tests/Derived/DataFamilies.hs view
@@ -27,7 +27,7 @@ -} module Derived.DataFamilies (       NotAllShow(..)-# if __GLASGOW_HASKELL__ >= 708+#if __GLASGOW_HASKELL__ >= 708     , NullaryClass(..)     , NullaryData(..) #endif@@ -35,21 +35,25 @@  #include "generic.h" +#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic)+import           GHC.Generics (Generic) # if defined(__LANGUAGE_DERIVE_GENERIC1__)-import GHC.Generics (Generic1)+import           GHC.Generics (Generic1) # endif #endif-import GHC.Show (appPrec, appPrec1, showSpace)+import           GHC.Show (appPrec, appPrec1, showSpace) -import Prelude ()-import Prelude.Compat+import           Prelude ()+import           Prelude.Compat -import Test.QuickCheck (Arbitrary(..), oneof)+import           Test.QuickCheck (Arbitrary(..), oneof)  #if MIN_VERSION_template_haskell(2,7,0)-import TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2)+import           TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2) #endif  import TransformersCompat (Show1(..), Show2(..))@@ -57,7 +61,7 @@ -------------------------------------------------------------------------------  data family NotAllShow-#if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKEL__ < 710+#if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKELL__ < 710     a b c d :: * #else     w x y z :: *@@ -95,11 +99,20 @@ $(deriveTextShow  'NASShow1) $(deriveTextShow1 'NASShow2) $(deriveTextShow2 'NASShow1)++# if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           'NASShow1)+$(Generics.deriveRepresentable1 'NASShow2)+# endif++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveRepresentable0 'NASShow1)+# endif #endif  ------------------------------------------------------------------------------- -# if __GLASGOW_HASKELL__ >= 708+#if __GLASGOW_HASKELL__ >= 708 class NullaryClass where     data NullaryData :: * @@ -108,4 +121,8 @@       deriving (Arbitrary, Show, Generic)  $(deriveTextShow 'NullaryCon)++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveAll 'NullaryCon) # endif+#endif
tests/Derived/Infix.hs view
@@ -1,10 +1,11 @@-{-# LANGUAGE CPP             #-}-{-# LANGUAGE GADTs           #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeFamilies    #-}+{-# LANGUAGE CPP               #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs             #-}+{-# LANGUAGE TemplateHaskell   #-}+{-# LANGUAGE TypeFamilies      #-}  #if __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE DeriveGeneric   #-}+{-# LANGUAGE DeriveGeneric     #-} #endif  {-|@@ -26,22 +27,26 @@  #include "generic.h" +#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-# if defined(__LANGUAGE_DERIVE_GENERIC1__)-import GHC.Generics (Generic1)+import           GHC.Generics (Generic)+# if __GLASGOW_HASKELL__ >= 706+import           GHC.Generics (Generic1) # endif #endif-import GHC.Show (appPrec, appPrec1, showSpace)+import           GHC.Show (appPrec, appPrec1, showSpace) -import Prelude ()-import Prelude.Compat+import           Prelude ()+import           Prelude.Compat -import Test.QuickCheck (Arbitrary(..), oneof)+import           Test.QuickCheck (Arbitrary(..), oneof) -import TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2)+import           TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2) -import TransformersCompat (Show1(..), Show2(..), showsBinaryWith)+import           TransformersCompat (Show1(..), Show2(..), showsBinaryWith)  ------------------------------------------------------------------------------- @@ -54,7 +59,7 @@   deriving ( Show #if __GLASGOW_HASKELL__ >= 702            , Generic-# if defined(__LANGUAGE_DERIVE_GENERIC1__)+# if __GLASGOW_HASKELL__ >= 706            , Generic1 # endif #endif@@ -71,9 +76,7 @@   deriving ( Show #if __GLASGOW_HASKELL__ >= 706            , Generic-# if defined(__LANGUAGE_DERIVE_GENERIC1__)            , Generic1-# endif #endif            ) @@ -228,4 +231,28 @@ $(deriveTextShow  '(:*)) $(deriveTextShow1 '(:***)) $(deriveTextShow2 '(:****))+#endif++#if __GLASGOW_HASKELL__ < 706+$(Generics.deriveMeta           ''TyConPlain)+$(Generics.deriveRepresentable1 ''TyConPlain)+$(Generics.deriveAll0And1       ''TyConGADT)+#endif++#if __GLASGOW_HASKELL__ < 702+$(Generics.deriveRepresentable0 ''TyConPlain)+#endif++#if MIN_VERSION_template_haskell(2,7,0)+# if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           '(:#:))+$(Generics.deriveRepresentable1 '(:$:))+$(Generics.deriveMeta           '(:*))+$(Generics.deriveRepresentable1 '(:**))+# endif++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveRepresentable0 'TyFamilyPlain)+$(Generics.deriveRepresentable0 '(:***))+# endif #endif
tests/Derived/MagicHash.hs view
@@ -3,6 +3,10 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies    #-} +#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE DeriveGeneric   #-}+#endif+ {-| Module:      Derived.MagicHash Copyright:   (C) 2014-2015 Ryan Scott@@ -15,56 +19,155 @@ -} module Derived.MagicHash (TyCon#(..), TyFamily#(..)) where -import GHC.Exts+#if __GLASGOW_HASKELL__ < 711+import qualified Generics.Deriving.TH as Generics+#endif -import Prelude ()-import Prelude.Compat+import           GHC.Exts+#if __GLASGOW_HASKELL__ >= 711+import           GHC.Generics (Generic, Generic1)+#endif+import           GHC.Show (showSpace)+#if __GLASGOW_HASKELL__ < 711+import           GHC.Show (appPrec)+#endif -import Test.QuickCheck (Arbitrary(..))+import           Prelude ()+import           Prelude.Compat -import TextShow.TH (deriveTextShow)+import           Test.QuickCheck (Arbitrary(..)) +import           TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2)++import           TransformersCompat (Show1(..), Show2(..))+ ------------------------------------------------------------------------------- -data TyCon# = TyCon# {-    tcInt#    :: Int#+data TyCon# a b = TyCon# {+    tcA       :: a+  , tcB       :: b+  , tcInt#    :: Int#   , tcFloat#  :: Float#   , tcDouble# :: Double#   , tcChar#   :: Char#   , tcWord#   :: Word#-} deriving Show-$(deriveTextShow ''TyCon#)+} deriving ( Show+#if __GLASGOW_HASKELL__ >= 711+           , Generic+           , Generic1+#endif+           )  -------------------------------------------------------------------------------  data family TyFamily#-data instance TyFamily# = TyFamily# {-    tfInt#    :: Int#+#if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKELL__ < 710+    a b :: *+#else+    y z :: *+#endif++data instance TyFamily# a b = TyFamily# {+    tfA       :: a+  , tfB       :: b+  , tfInt#    :: Int#   , tfFloat#  :: Float#   , tfDouble# :: Double#   , tfChar#   :: Char#   , tfWord#   :: Word#-} deriving Show-#if MIN_VERSION_template_haskell(2,7,0)-$(deriveTextShow 'TyFamily#)+} deriving ( Show+#if __GLASGOW_HASKELL__ >= 711+           , Generic+           , Generic1 #endif+           )  ------------------------------------------------------------------------------- -instance Arbitrary TyCon# where+instance (Arbitrary a, Arbitrary b) => Arbitrary (TyCon# a b) where     arbitrary = do+        a     <- arbitrary+        b     <- arbitrary         I# i# <- arbitrary         F# f# <- arbitrary         D# d# <- arbitrary         C# c# <- arbitrary         W# w# <- arbitrary-        pure $ TyCon# i# f# d# c# w#+        pure $ TyCon# a b i# f# d# c# w# -instance Arbitrary TyFamily# where+instance (Arbitrary a, Arbitrary b) => Arbitrary (TyFamily# a b) where     arbitrary = do+        a     <- arbitrary+        b     <- arbitrary         I# i# <- arbitrary         F# f# <- arbitrary         D# d# <- arbitrary         C# c# <- arbitrary         W# w# <- arbitrary-        pure $ TyFamily# i# f# d# c# w#+        pure $ TyFamily# a b i# f# d# c# w#++-------------------------------------------------------------------------------++instance Show a => Show1 (TyCon# a) where+    showsPrecWith = showsPrecWith2 showsPrec+instance Show2 TyCon# where+    showsPrecWith2 sp1 sp2 p (TyCon# a b i f d c w) =+        showsHash sp1 sp2 "TyCon#" "tcA" "tcB" "tcInt#" "tcFloat#"+                  "tcDouble#" "tcChar#" "tcWord#" p a b i f d c w++instance Show a => Show1 (TyFamily# a) where+    showsPrecWith = showsPrecWith2 showsPrec+instance Show2 TyFamily# where+    showsPrecWith2 sp1 sp2 p (TyFamily# a b i f d c w) =+        showsHash sp1 sp2 "TyFamily#" "tfA" "tfB" "tfInt#" "tfFloat#"+                  "tfDouble#" "tfChar#" "tfWord#" p a b i f d c w++showsHash :: (Int -> a -> ShowS) -> (Int -> b -> ShowS)+          -> String -> String -> String -> String -> String -> String -> String -> String+          -> Int -> a -> b -> Int# -> Float# -> Double# -> Char# -> Word#+          -> ShowS+showsHash sp1 sp2 con rec1 rec2 rec3 rec4 rec5 rec6 rec7 _p a b i f d c w =+#if __GLASGOW_HASKELL__ < 711+    showParen (_p > appPrec) $+#endif+          showString con . showSpace+        . showChar '{'+        . showString rec1 . equals . sp1 0 a                . comma+        . showString rec2 . equals . sp2 0 b                . comma+        . showString rec3 . equals . shows (I# i) . oneHash . comma+        . showString rec4 . equals . shows (F# f) . oneHash . comma+        . showString rec5 . equals . shows (D# d) . twoHash . comma+        . showString rec6 . equals . shows (C# c) . oneHash . comma+        . showString rec7 . equals . shows (W# w) . twoHash+        . showChar '}'+  where+    comma, equals :: ShowS+    comma  = showString ", "+    equals = showString " = "++    oneHash, twoHash :: ShowS+#if __GLASGOW_HASKELL__ >= 711+    oneHash  = showChar '#'+    twoHash  = showString "##"+#else+    oneHash  = id+    twoHash  = id+#endif++-------------------------------------------------------------------------------++$(deriveTextShow  ''TyCon#)+$(deriveTextShow1 ''TyCon#)+$(deriveTextShow2 ''TyCon#)+#if MIN_VERSION_template_haskell(2,7,0)+$(deriveTextShow  'TyFamily#)+$(deriveTextShow1 'TyFamily#)+$(deriveTextShow2 'TyFamily#)+#endif++#if __GLASGOW_HASKELL__ < 711+$(Generics.deriveAll0And1 ''TyCon#)+# if MIN_VERSION_template_haskell(2,7,0)+$(Generics.deriveAll0And1 'TyFamily#)+# endif+#endif
tests/Derived/PolyKinds.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE StandaloneDeriving         #-} {-# LANGUAGE TemplateHaskell            #-} {-# LANGUAGE TypeFamilies               #-}+{-# LANGUAGE TypeOperators              #-} {-# LANGUAGE UndecidableInstances       #-}  #if __GLASGOW_HASKELL__ >= 702@@ -35,14 +36,11 @@  #include "generic.h" -#if __GLASGOW_HASKELL__ >= 702-import           GHC.Generics (Generic)-# if defined(__LANGUAGE_DERIVE_GENERIC1__)-import           GHC.Generics (Generic1)-# endif-#else-import qualified Generics.Deriving.TH as Generics (deriveAll)+import           Generics.Deriving.Base+#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+import qualified Generics.Deriving.TH as Generics #endif+ import           GHC.Show (appPrec, appPrec1, showSpace)  import           Test.QuickCheck (Arbitrary)@@ -64,11 +62,11 @@ deriving instance Arbitrary (f (g (j a) (k a)) (h (j a) (k b))) =>   Arbitrary (TyConCompose f g h j k a b) -# if defined(__LANGUAGE_DERIVE_GENERIC1__)+#if defined(__LANGUAGE_DERIVE_GENERIC1__) deriving instance ( Functor (f (g (j a) (k a)))                   , Functor (h (j a))                   ) => Generic1 (TyConCompose f g h j k a)-# endif+#endif  deriving instance Show (f (g (j a) (k a)) (h (j a) (k b))) =>   Show (TyConCompose f g h j k a b)@@ -138,11 +136,11 @@ deriving instance Arbitrary (f (g (j a) (k a)) (h (j a) (k b))) =>   Arbitrary (TyFamilyCompose f g h j k a b) -# if defined(__LANGUAGE_DERIVE_GENERIC1__)+#if defined(__LANGUAGE_DERIVE_GENERIC1__) deriving instance ( Functor (f (g (j a) (k a)))                   , Functor (h (j a))                   ) => Generic1 (TyFamilyCompose f g h j k a)-# endif+#endif  deriving instance Show (f (g (j a) (k a)) (h (j a) (k b))) =>   Show (TyFamilyCompose f g h j k a b)@@ -321,8 +319,50 @@     showbPrecWith2 = $(makeShowbPrecWith2 'TyFamilyReallyHighKinds) #endif +#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           ''TyConCompose)+$(Generics.deriveRep1           ''TyConCompose)++instance ( Functor (f (g (j a) (k a)))+         , Functor (h (j a))+         ) => Generic1 (TyConCompose f g h j k a) where+    type Rep1 (TyConCompose f g h j k a) = $(Generics.makeRep1 ''TyConCompose) f g h j k a+    from1 = $(Generics.makeFrom1 ''TyConCompose)+    to1   = $(Generics.makeTo1   ''TyConCompose)++$(Generics.deriveMeta           ''TyConProxy)+$(Generics.deriveRepresentable1 ''TyConProxy)+$(Generics.deriveMeta           ''TyConReallyHighKinds)+$(Generics.deriveRepresentable1 ''TyConReallyHighKinds)+#endif+ #if __GLASGOW_HASKELL__ < 702-$(Generics.deriveAll ''TyConCompose)-$(Generics.deriveAll ''TyConProxy)-$(Generics.deriveAll ''TyConReallyHighKinds)+$(Generics.deriveRepresentable0 ''TyConCompose)+$(Generics.deriveRepresentable0 ''TyConProxy)+$(Generics.deriveRepresentable0 ''TyConReallyHighKinds)+#endif++#if MIN_VERSION_template_haskell(2,7,0)+# if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           'TyFamilyCompose)+$(Generics.deriveRep1           'TyFamilyCompose)++instance ( Functor (f (g (j a) (k a)))+         , Functor (h (j a))+         ) => Generic1 (TyFamilyCompose f g h j k a) where+    type Rep1 (TyFamilyCompose f g h j k a) = $(Generics.makeRep1 'TyFamilyCompose) f g h j k a+    from1 = $(Generics.makeFrom1 'TyFamilyCompose)+    to1   = $(Generics.makeTo1   'TyFamilyCompose)++$(Generics.deriveMeta           'TyFamilyProxy)+$(Generics.deriveRepresentable1 'TyFamilyProxy)+$(Generics.deriveMeta           'TyFamilyReallyHighKinds)+$(Generics.deriveRepresentable1 'TyFamilyReallyHighKinds)+# endif++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveRepresentable0 'TyFamilyCompose)+$(Generics.deriveRepresentable0 'TyFamilyProxy)+$(Generics.deriveRepresentable0 'TyFamilyReallyHighKinds)+# endif #endif
tests/Derived/Records.hs view
@@ -20,25 +20,29 @@  #include "generic.h" +#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-# if defined(__LANGUAGE_DERIVE_GENERIC1__)-import GHC.Generics (Generic1)+import           GHC.Generics (Generic)+# if __GLASGOW_HASKELL__ >= 706+import           GHC.Generics (Generic1) # endif #endif-import GHC.Show (showSpace)+import           GHC.Show (showSpace) #if __GLASGOW_HASKELL__ < 711-import GHC.Show (appPrec)+import           GHC.Show (appPrec) #endif -import Prelude ()-import Prelude.Compat+import           Prelude ()+import           Prelude.Compat -import Test.QuickCheck (Arbitrary(..), oneof)+import           Test.QuickCheck (Arbitrary(..), oneof) -import TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2)+import           TextShow.TH (deriveTextShow, deriveTextShow1, deriveTextShow2) -import TransformersCompat (Show1(..), Show2(..))+import           TransformersCompat (Show1(..), Show2(..))  ------------------------------------------------------------------------------- @@ -48,7 +52,7 @@   deriving ( Show #if __GLASGOW_HASKELL__ >= 702            , Generic-# if defined(__LANGUAGE_DERIVE_GENERIC1__)+# if __GLASGOW_HASKELL__ >= 706            , Generic1 # endif #endif@@ -127,4 +131,24 @@ $(deriveTextShow  'TyFamilyPrefix) $(deriveTextShow1 '(:!:)) $(deriveTextShow2 'TyFamilyPrefix)+#endif++#if __GLASGOW_HASKELL__ < 706+$(Generics.deriveMeta           ''TyCon)+$(Generics.deriveRepresentable1 ''TyCon)+#endif++#if __GLASGOW_HASKELL__ < 702+$(Generics.deriveRepresentable0 ''TyCon)+#endif++#if MIN_VERSION_template_haskell(2,7,0)+# if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           'TyFamilyPrefix)+$(Generics.deriveRepresentable1 '(:!:))+# endif++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveRepresentable0 'TyFamilyPrefix)+# endif #endif
tests/Derived/TypeSynonyms.hs view
@@ -23,13 +23,15 @@  #include "generic.h" +#if !defined(__LANGUAGE_DERIVE_GENERIC1__)+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 702 import           GHC.Generics (Generic)-# if defined(__LANGUAGE_DERIVE_GENERIC1__)+# if __GLASGOW_HASKELL__ >= 706 import           GHC.Generics (Generic1) # endif-#else-import qualified Generics.Deriving.TH as Generics (deriveAll) #endif  import           Prelude@@ -70,7 +72,7 @@            , Show #if __GLASGOW_HASKELL__ >= 702            , Generic-# if defined(__LANGUAGE_DERIVE_GENERIC1__)+# if __GLASGOW_HASKELL__ >= 706            , Generic1 # endif #endif@@ -131,6 +133,22 @@ $(deriveTextShow2 'TyFamily) #endif +#if __GLASGOW_HASKELL__ < 706+$(Generics.deriveMeta           ''TyCon)+$(Generics.deriveRepresentable1 ''TyCon)+#endif+ #if __GLASGOW_HASKELL__ < 702-$(Generics.deriveAll ''TyCon)+$(Generics.deriveRepresentable0 ''TyCon)+#endif++#if MIN_VERSION_template_haskell(2,7,0)+# if !defined(__LANGUAGE_DERIVE_GENERIC1__)+$(Generics.deriveMeta           'TyFamily)+$(Generics.deriveRepresentable1 'TyFamily)+# endif++# if __GLASGOW_HASKELL__ < 706+$(Generics.deriveRepresentable0 'TyFamily)+# endif #endif
tests/Instances/Control/Exception.hs view
@@ -98,7 +98,7 @@     arbitrary = RecUpdError <$> arbitrary  instance Arbitrary ErrorCall where-#if MIN_VERSION_base(4,8,2)+#if MIN_VERSION_base(4,9,0)     arbitrary = ErrorCallWithLocation <$> arbitrary <*> arbitrary #else     arbitrary = ErrorCall <$> arbitrary
tests/Instances/GHC/Generics.hs view
@@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts           #-}+{-# LANGUAGE FlexibleInstances          #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MagicHash                  #-} {-# LANGUAGE StandaloneDeriving         #-} {-# LANGUAGE TypeOperators              #-}+{-# LANGUAGE TypeSynonymInstances       #-} {-# OPTIONS_GHC -fno-warn-orphans #-}  {-|@@ -16,10 +19,10 @@ -} module Instances.GHC.Generics () where -import Generics.Deriving.Base (U1(..), Par1(..), Rec1(..), K1(..),-                               M1(..), (:+:)(..), (:*:)(..), (:.:)(..),-                               Fixity(..), Associativity(..), Arity(..))+import Generics.Deriving.Base +import GHC.Exts (Char(C#), Double(D#), Float(F#), Int(I#), Word(W#))+ import Prelude () import Prelude.Compat @@ -50,3 +53,28 @@  instance Arbitrary Arity where     arbitrary = oneof [pure NoArity, Arity <$> arbitrary]++instance Arbitrary (UChar p) where+    arbitrary = do+        C# c <- arbitrary+        pure $ UChar c++instance Arbitrary (UDouble p) where+    arbitrary = do+        D# d <- arbitrary+        pure $ UDouble d++instance Arbitrary (UFloat p) where+    arbitrary = do+        F# f <- arbitrary+        pure $ UFloat f++instance Arbitrary (UInt p) where+    arbitrary = do+        I# i <- arbitrary+        pure $ UInt i++instance Arbitrary (UWord p) where+    arbitrary = do+        W# w <- arbitrary+        pure $ UWord w
tests/Spec/Data/ProxySpec.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ {-| Module:      Spec.Data.ProxySpec Copyright:   (C) 2014-2015 Ryan Scott@@ -14,7 +16,10 @@  import Instances.Data.Proxy () -import Spec.Utils (prop_matchesTextShow, prop_genericTextShow)+import Spec.Utils (prop_matchesTextShow)+#if __GLASGOW_HASKELL__ >= 702+import Spec.Utils (prop_genericTextShow)+#endif  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -25,4 +30,6 @@ spec :: Spec spec = parallel . describe "Proxy Int" $ do     prop "TextShow instance" (prop_matchesTextShow :: Int -> Proxy Int -> Bool)+#if __GLASGOW_HASKELL__ >= 702     prop "generic TextShow"  (prop_genericTextShow :: Int -> Proxy Int -> Bool)+#endif
tests/Spec/Derived/DataFamiliesSpec.hs view
@@ -20,7 +20,7 @@ #if MIN_VERSION_template_haskell(2,7,0) import Derived.DataFamilies (NotAllShow) -import Spec.Utils (prop_matchesTextShow2, prop_genericTextShow', prop_genericTextShow1)+import Spec.Utils (prop_matchesTextShow2, prop_genericTextShow, prop_genericTextShow1)  import Test.Hspec (describe) import Test.Hspec.QuickCheck (prop)@@ -39,12 +39,12 @@ #if MIN_VERSION_template_haskell(2,7,0)     describe "NotAllShow Int Int Int Int" $ do         prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> NotAllShow Int Int Int Int -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> NotAllShow Int Int Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> NotAllShow Int Int Int Int -> Bool)         prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> NotAllShow Int Int Int Int -> Bool) # if __GLASGOW_HASKELL__ >= 708     describe "NullaryData" $ do         prop "TextShow instance"  (prop_matchesTextShow  :: Int -> NullaryData -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> NullaryData -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> NullaryData -> Bool) # endif #else     pure ()
tests/Spec/Derived/InfixSpec.hs view
@@ -14,8 +14,7 @@  import Derived.Infix -import Spec.Utils (prop_matchesTextShow, prop_genericTextShow,-                   prop_genericTextShow', prop_genericTextShow1)+import Spec.Utils (prop_matchesTextShow, prop_genericTextShow, prop_genericTextShow1)  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -31,15 +30,15 @@         prop "generic TextShow1" (prop_genericTextShow1 :: Int -> TyConPlain Int Int -> Bool)     describe "TyConGADT Int Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> TyConGADT Int Int -> Bool)-        prop "generic TextShow"  (prop_genericTextShow' :: Int -> TyConGADT Int Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> TyConGADT Int Int -> Bool)         prop "generic TextShow1" (prop_genericTextShow1 :: Int -> TyConGADT Int Int -> Bool) #if MIN_VERSION_template_haskell(2,7,0)     describe "TyFamilyPlain Int Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> TyFamilyPlain Int Int -> Bool)-        prop "generic TextShow"  (prop_genericTextShow' :: Int -> TyFamilyPlain Int Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> TyFamilyPlain Int Int -> Bool)         prop "generic TextShow1" (prop_genericTextShow1 :: Int -> TyFamilyPlain Int Int -> Bool)     describe "TyFamilyGADT Int Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> TyFamilyGADT Int Int -> Bool)-        prop "generic TextShow"  (prop_genericTextShow' :: Int -> TyFamilyGADT Int Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> TyFamilyGADT Int Int -> Bool)         prop "generic TextShow1" (prop_genericTextShow1 :: Int -> TyFamilyGADT Int Int -> Bool) #endif
tests/Spec/Derived/MagicHashSpec.hs view
@@ -15,7 +15,7 @@  import Derived.MagicHash -import Spec.Utils (prop_matchesTextShow)+import Spec.Utils (prop_matchesTextShow2, prop_genericTextShow, prop_genericTextShow1)  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -25,9 +25,13 @@  spec :: Spec spec = parallel $ do-    describe "TyCon#" $-        prop "TextShow instance" (prop_matchesTextShow :: Int -> TyCon# -> Bool)+    describe "TyCon# Int Int" $ do+        prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyCon# Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyCon# Int Int -> Bool)+        prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyCon# Int Int -> Bool) #if MIN_VERSION_template_haskell(2,7,0)-    describe "TyFamily#" $-        prop "TextShow instance" (prop_matchesTextShow :: Int -> TyFamily# -> Bool)+    describe "TyFamily# Int Int" $ do+        prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyFamily# Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyFamily# Int Int -> Bool)+        prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyFamily# Int Int -> Bool) #endif
tests/Spec/Derived/PolyKindsSpec.hs view
@@ -15,9 +15,6 @@ import Derived.PolyKinds  import Spec.Utils (prop_matchesTextShow2, prop_genericTextShow, prop_genericTextShow1)-#if MIN_VERSION_template_haskell(2,7,0)-import Spec.Utils (prop_genericTextShow')-#endif  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -42,14 +39,14 @@ #if MIN_VERSION_template_haskell(2,7,0)     describe "TyFamilyCompose Either Either Either Maybe Maybe Int Int" $ do         prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyFamilyCompose Either Either Either Maybe Maybe Int Int -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> TyFamilyCompose Either Either Either Maybe Maybe Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyFamilyCompose Either Either Either Maybe Maybe Int Int -> Bool)         prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyFamilyCompose Either Either Either Maybe Maybe Int Int -> Bool)     describe "TyFamilyProxy Int Int" $ do         prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyFamilyProxy Int Int -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> TyFamilyProxy Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyFamilyProxy Int Int -> Bool)         prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyFamilyProxy Int Int -> Bool)     describe "TyFamilyReallyHighKinds (,,,,) Int Int Int Int Int" $ do         prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyFamilyReallyHighKinds (,,,,) Int Int Int Int Int -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> TyFamilyReallyHighKinds (,,,,) Int Int Int Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyFamilyReallyHighKinds (,,,,) Int Int Int Int Int -> Bool)         prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyFamilyReallyHighKinds (,,,,) Int Int Int Int Int -> Bool) #endif
tests/Spec/Derived/RecordsSpec.hs view
@@ -15,9 +15,6 @@ import Derived.Records  import Spec.Utils (prop_matchesTextShow2, prop_genericTextShow, prop_genericTextShow1)-#if MIN_VERSION_template_haskell(2,7,0)-import Spec.Utils (prop_genericTextShow')-#endif  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -34,6 +31,6 @@ #if MIN_VERSION_template_haskell(2,7,0)     describe "TyFamily Int Int" $ do         prop "TextShow2 instance" (prop_matchesTextShow2 :: Int -> TyFamily Int Int -> Bool)-        prop "generic TextShow"   (prop_genericTextShow' :: Int -> TyFamily Int Int -> Bool)+        prop "generic TextShow"   (prop_genericTextShow  :: Int -> TyFamily Int Int -> Bool)         prop "generic TextShow1"  (prop_genericTextShow1 :: Int -> TyFamily Int Int -> Bool) #endif
tests/Spec/Derived/TypeSynonymsSpec.hs view
@@ -15,9 +15,6 @@ import Derived.TypeSynonyms  import Spec.Utils (prop_matchesTextShow, prop_genericTextShow, prop_genericTextShow1)-#if MIN_VERSION_template_haskell(2,7,0)-import Spec.Utils (prop_genericTextShow')-#endif  import Test.Hspec (Spec, describe, hspec, parallel) import Test.Hspec.QuickCheck (prop)@@ -34,6 +31,6 @@ #if MIN_VERSION_template_haskell(2,7,0)     describe "TyFamily Int Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> TyFamily Int Int -> Bool)-        prop "generic TextShow"  (prop_genericTextShow' :: Int -> TyFamily Int Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> TyFamily Int Int -> Bool)         prop "generic TextShow1" (prop_genericTextShow1 :: Int -> TyFamily Int Int -> Bool) #endif
tests/Spec/GHC/GenericsSpec.hs view
@@ -15,6 +15,7 @@ import Data.Orphans ()  import Generics.Deriving.Base (U1, Par1, Rec1, K1, M1, (:+:), (:*:), (:.:),+                               UChar, UDouble, UFloat, UInt, UWord,                                Fixity, Associativity, Arity) import Generics.Deriving.Instances () @@ -54,12 +55,27 @@     describe "M1 () () Maybe Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> M1 () () Maybe Int -> Bool)         prop "generic TextShow"  (prop_genericTextShow  :: Int -> M1 () () Maybe Int -> Bool)-    describe "(Maybe :+: Maybe) Int " $ do+    describe "(Maybe :+: Maybe) Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> (Maybe :+: Maybe) Int -> Bool)         prop "generic TextShow"  (prop_genericTextShow  :: Int -> (Maybe :+: Maybe) Int -> Bool)-    describe "(Maybe :*: Maybe) Int " $ do+    describe "(Maybe :*: Maybe) Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> (Maybe :*: Maybe) Int -> Bool)         prop "generic TextShow"  (prop_genericTextShow  :: Int -> (Maybe :*: Maybe) Int -> Bool)-    describe "(Maybe :.: Maybe) Int " $ do+    describe "(Maybe :.: Maybe) Int" $ do         prop "TextShow instance" (prop_matchesTextShow  :: Int -> (Maybe :.: Maybe) Int -> Bool)         prop "generic TextShow"  (prop_genericTextShow  :: Int -> (Maybe :.: Maybe) Int -> Bool)+    describe "UChar Int" $ do+        prop "TextShow instance" (prop_matchesTextShow  :: Int -> UChar Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> UChar Int -> Bool)+    describe "UDouble Int" $ do+        prop "TextShow instance" (prop_matchesTextShow  :: Int -> UDouble Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> UDouble Int -> Bool)+    describe "UFloat Int" $ do+        prop "TextShow instance" (prop_matchesTextShow  :: Int -> UFloat Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> UFloat Int -> Bool)+    describe "UInt Int" $ do+        prop "TextShow instance" (prop_matchesTextShow  :: Int -> UInt Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> UInt Int -> Bool)+    describe "UWord Int" $ do+        prop "TextShow instance" (prop_matchesTextShow  :: Int -> UWord Int -> Bool)+        prop "generic TextShow"  (prop_genericTextShow  :: Int -> UWord Int -> Bool)
tests/Spec/Utils.hs view
@@ -16,19 +16,12 @@     , prop_matchesTextShow1     , prop_matchesTextShow2     , prop_genericTextShow-    , prop_genericTextShow'     , prop_genericTextShow1     ) where  #include "generic.h" -#if __GLASGOW_HASKELL__ >= 702-import           GHC.Generics (Generic, Rep)-# if defined(__LANGUAGE_DERIVE_GENERIC1__)-import           GHC.Generics (Generic1, Rep1)-# endif-import           TextShow.Generic-#endif+import           Generics.Deriving.Base  #if MIN_VERSION_QuickCheck(2,7,0) import qualified Test.QuickCheck as QC (ioProperty)@@ -39,6 +32,7 @@  import           TextShow (TextShow(..), TextShow1(..), TextShow2(..),                            Builder, FromStringShow(..))+import           TextShow.Generic  import           TransformersCompat (Show1, Show2,                                     FromStringShow1(..), FromStringShow2(..))@@ -79,35 +73,13 @@  -- | Verifies that a type's 'TextShow' instance coincides with the output produced -- by the equivalent 'Generic' functions.-#if __GLASGOW_HASKELL__ >= 702 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 --- | Behaves exactly like 'prop_genericTextShow', except only for GHC 7.6 and above.--- This is useful with type families, which couldn't properly have derived 'Generic'--- instances until GHC 7.6 due to a bug.-#if __GLASGOW_HASKELL__ >= 706-prop_genericTextShow' :: (TextShow a, Generic a, GTextShow (Rep a))-                       => Int -> a -> Bool-prop_genericTextShow' = prop_genericTextShow-#else-prop_genericTextShow' :: Int -> f a -> Bool-prop_genericTextShow' _ _ = True-#endif- -- | Verifies that a type's 'TextShow1' instance coincides with the output produced -- by the equivalent 'Generic1' functions.-#if defined(__LANGUAGE_DERIVE_GENERIC1__) prop_genericTextShow1 :: (TextShow1 f, Generic1 f, GTextShow1 (Rep1 f))                       => 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
tests/TransformersCompat.hs view
@@ -5,14 +5,15 @@ {-# LANGUAGE DeriveTraversable          #-} {-# LANGUAGE FlexibleContexts           #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TemplateHaskell            #-}+{-# LANGUAGE TypeFamilies               #-}  #if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric              #-}-#else-{-# LANGUAGE TemplateHaskell            #-}-{-# LANGUAGE TypeFamilies               #-} #endif +{-# OPTIONS_GHC -fno-warn-name-shadowing #-}+ {-| Module:      TransformersCompat Copyright:   (C) 2014-2015 Ryan Scott@@ -42,19 +43,22 @@  import           Control.Applicative (Const(..)) -import           Data.Bifunctor (Bifunctor(..))+import           Data.Bifunctor.TH (deriveBifunctor, deriveBifoldable,+                                    deriveBitraversable) #if __GLASGOW_HASKELL__ >= 708 import           Data.Data (Data, Typeable) #endif import           Data.Functor.Identity (Identity(..)) +#if __GLASGOW_HASKELL__ < 706+import qualified Generics.Deriving.TH as Generics+#endif+ #if __GLASGOW_HASKELL__ >= 702 import           GHC.Generics (Generic) # if __GLASGOW_HASKELL__ >= 706 import           GHC.Generics (Generic1) # endif-#else-import qualified Generics.Deriving.TH as Generics #endif  import           Prelude ()@@ -209,10 +213,6 @@ #endif            ) -instance Bifunctor f => Bifunctor (FromStringShow2 f) where-    bimap f g = FromStringShow2 . bimap f g . fromStringShow2-    INLINE_INST_FUN(bimap)- instance Read (f a b) => Read (FromStringShow2 f a b) where     readPrec = FromStringShow2 <$> readPrec     INLINE_INST_FUN(readPrec)@@ -269,10 +269,6 @@ #endif            ) -instance Bifunctor f => Bifunctor (FromTextShow2 f) where-    bimap f g = FromTextShow2 . bimap f g . fromTextShow2-    INLINE_INST_FUN(bimap)- instance Read (f a b) => Read (FromTextShow2 f a b) where     readPrec = FromTextShow2 <$> readPrec     INLINE_INST_FUN(readPrec)@@ -374,7 +370,27 @@  ------------------------------------------------------------------------------- +$(deriveBifunctor     ''FromStringShow2)+$(deriveBifunctor     ''FromTextShow2)+$(deriveBifoldable    ''FromStringShow2)+$(deriveBifoldable    ''FromTextShow2)+$(deriveBitraversable ''FromStringShow2)+$(deriveBitraversable ''FromTextShow2)++#if __GLASGOW_HASKELL__ < 706+$(Generics.deriveMeta           ''FromStringShow1)+$(Generics.deriveRepresentable1 ''FromStringShow1)+$(Generics.deriveMeta           ''FromTextShow1)+$(Generics.deriveRepresentable1 ''FromTextShow1)+$(Generics.deriveMeta           ''FromStringShow2)+$(Generics.deriveRepresentable1 ''FromStringShow2)+$(Generics.deriveMeta           ''FromTextShow2)+$(Generics.deriveRepresentable1 ''FromTextShow2)+#endif+ #if __GLASGOW_HASKELL__ < 702-$(Generics.deriveAll ''FromStringShow1)-$(Generics.deriveAll ''FromStringShow2)+$(Generics.deriveRepresentable0 ''FromStringShow1)+$(Generics.deriveRepresentable0 ''FromStringShow2)+$(Generics.deriveRepresentable0 ''FromTextShow1)+$(Generics.deriveRepresentable0 ''FromTextShow2) #endif
text-show.cabal view
@@ -1,5 +1,5 @@ name:                text-show-version:             2.1.1+version:             2.1.2 synopsis:            Efficient conversion of values into Text description:         @text-show@ offers a replacement for the @Show@ typeclass intended                      for use with @Text@ instead of @String@s. This package was created@@ -33,14 +33,13 @@                      page for more information.                      .                      Support for automatically deriving @TextShow@ instances can be found-                     in the "TextShow.TH" and "TextShow.Generic" modules. If you don't-                     know which one to use, use "TextShow.TH".+                     in the "TextShow.TH" and "TextShow.Generic" modules. homepage:            https://github.com/RyanGlScott/text-show bug-reports:         https://github.com/RyanGlScott/text-show/issues 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:           Provisional copyright:           (C) 2014-2015 Ryan Scott category:            Text@@ -50,7 +49,7 @@                    , GHC == 7.4.2                    , GHC == 7.6.3                    , GHC == 7.8.4-                   , GHC == 7.10.2+                   , GHC == 7.10.3 extra-source-files:  CHANGELOG.md, README.md, include/*.h cabal-version:       >=1.10 @@ -58,6 +57,11 @@   type:                git   location:            https://github.com/RyanGlScott/text-show +flag developer+  description:         Operate in developer mode (allows for faster recompilation of tests)+  default:             False+  manual:              True+ library   exposed-modules:     TextShow                        TextShow.Control.Applicative@@ -138,7 +142,7 @@                      , bytestring         >= 0.9     && < 0.11                      , bytestring-builder                      , containers         >= 0.1     && < 0.6-                     , generic-deriving   >= 1.8     && < 2+                     , generic-deriving   >= 1.9     && < 2                      , ghc-prim                      , integer-gmp                      , nats               >= 0.1     && < 2@@ -303,10 +307,10 @@                      , base                 >= 4.3    && < 5                      , base-compat          >= 0.8.2  && < 1                      , base-orphans         >= 0.4.2  && < 1-                     , bifunctors           >= 5      && < 6+                     , bifunctors           >= 5.1    && < 6                      , bytestring           >= 0.9    && < 0.11                      , bytestring-builder-                     , generic-deriving     >= 1.8.0  && < 2+                     , generic-deriving     >= 1.9    && < 2                      , ghc-prim                      , hspec                >= 2      && < 3                      , nats                 >= 0.1    && < 2@@ -314,11 +318,21 @@                      , quickcheck-instances >= 0.1    && < 0.4                      , tagged               >= 0.8.1  && < 1                      , text                 >= 0.11.1 && < 1.3-                     , text-show            == 2.1.1                      , transformers         >= 0.2.1  && < 0.5                      , transformers-compat  >= 0.3    && < 1                      , void                 >= 0.5    && < 1+  if flag(developer)+    build-depends:     containers           >= 0.1    && < 0.6+                     , integer-gmp+                     , semigroups           >= 0.16.1 && < 1+                     , template-haskell     >= 2.5    && < 2.12+  else+    build-depends:     text-show            == 2.1.2+   hs-source-dirs:      tests+  if flag(developer)+    hs-source-dirs:    src+   default-language:    Haskell2010   ghc-options:         -Wall -threaded -rtsopts   include-dirs:        include