text-show-instances 0.4 → 1
raw patch · 84 files changed
+6125/−5574 lines, 84 filesdep +bifunctorsdep +ghc-primdep +th-orphansdep −utf8-stringdep ~text-showdep ~text-show-instancessetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: bifunctors, ghc-prim, th-orphans
Dependencies removed: utf8-string
Dependency ranges changed: text-show, text-show-instances
API changes (from Hackage documentation)
- Text.Show.Text.Compiler.Hoopl: showbLabelMapPrec :: Show v => Int -> LabelMap v -> Builder
- Text.Show.Text.Compiler.Hoopl: showbPointed :: Show a => Pointed t b a -> Builder
- Text.Show.Text.Compiler.Hoopl: showbUniqueMapPrec :: Show v => Int -> UniqueMap v -> Builder
- Text.Show.Text.Control.Applicative.Trans: showbBackwardsPrec :: (Show1 f, Show a) => Int -> Backwards f a -> Builder
- Text.Show.Text.Control.Applicative.Trans: showbLiftPrec :: (Show1 f, Show a) => Int -> Lift f a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbErrorTPrec :: (Show e, Show1 m, Show a) => Int -> ErrorT e m a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbExceptTPrec :: (Show e, Show1 m, Show a) => Int -> ExceptT e m a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbIdentityTPrec :: (Show1 f, Show a) => Int -> IdentityT f a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbMaybeTPrec :: (Show1 m, Show a) => Int -> MaybeT m a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbWriterTLazyPrec :: (Show w, Show1 m, Show a) => Int -> WriterT w m a -> Builder
- Text.Show.Text.Control.Monad.Trans: showbWriterTStrictPrec :: (Show w, Show1 m, Show a) => Int -> WriterT w m a -> Builder
- Text.Show.Text.Data.Binary: showbDecoder :: Show a => Decoder a -> Builder
- Text.Show.Text.Data.Containers: showbIntMapPrec :: Show v => Int -> IntMap v -> Builder
- Text.Show.Text.Data.Containers: showbMapPrec :: (Show k, Show v) => Int -> Map k v -> Builder
- Text.Show.Text.Data.Functor.Trans: instance (Functor f, Show1 f, Show1 g) => Show1 (Compose f g)
- Text.Show.Text.Data.Functor.Trans: instance (Functor f, Show1 f, Show1 g, Show a) => Show (Compose f g a)
- Text.Show.Text.Data.Functor.Trans: instance (Show1 g, Show a) => Show (Apply g a)
- Text.Show.Text.Data.Functor.Trans: showbComposePrec :: (Functor f, Show1 f, Show1 g, Show a) => Int -> Compose f g a -> Builder
- Text.Show.Text.Data.Functor.Trans: showbConstantPrec :: Show a => Int -> Constant a b -> Builder
- Text.Show.Text.Data.Functor.Trans: showbProductPrec :: (Show1 f, Show1 g, Show a) => Int -> Product f g a -> Builder
- Text.Show.Text.Data.Functor.Trans: showbReversePrec :: (Show1 f, Show a) => Int -> Reverse f a -> Builder
- Text.Show.Text.Data.Functor.Trans: showbSumPrec :: (Show1 f, Show1 g, Show a) => Int -> Sum f g a -> Builder
- Text.Show.Text.Data.List.NonEmpty: showbNonEmptyPrec :: Show a => Int -> NonEmpty a -> Builder
- Text.Show.Text.Data.Semigroup: instance Show a => Show1 (Arg a)
- Text.Show.Text.Data.Semigroup: showbArgPrec :: (Show a, Show b) => Int -> Arg a b -> Builder
- Text.Show.Text.Data.Semigroup: showbFirstPrec :: Show a => Int -> First a -> Builder
- Text.Show.Text.Data.Semigroup: showbLastPrec :: Show a => Int -> Last a -> Builder
- Text.Show.Text.Data.Semigroup: showbMaxPrec :: Show a => Int -> Max a -> Builder
- Text.Show.Text.Data.Semigroup: showbMinPrec :: Show a => Int -> Min a -> Builder
- Text.Show.Text.Data.Semigroup: showbOptionPrec :: Show a => Int -> Option a -> Builder
- Text.Show.Text.Data.Semigroup: showbWrappedMonoidPrec :: Show m => Int -> WrappedMonoid m -> Builder
- Text.Show.Text.Data.String.UTF8: instance UTF8Bytes string index => Show (UTF8 string)
- Text.Show.Text.Data.String.UTF8: showbUTF8 :: UTF8Bytes string index => UTF8 string -> Builder
- Text.Show.Text.Data.String.UTF8: toBuilder :: UTF8Bytes string index => UTF8 string -> Builder
- Text.Show.Text.Data.String.UTF8: toBuilderGeneric :: UTF8Bytes bytestring index => bytestring -> Builder
- Text.Show.Text.Data.Tagged: showbTaggedPrec :: Show b => Int -> Tagged s b -> Builder
- Text.Show.Text.Data.UnorderedContainers: showbHashMapPrec :: (Show k, Show v) => Int -> HashMap k v -> Builder
+ Text.Show.Text.Compiler.Hoopl: instance Show2 (Pointed t)
+ Text.Show.Text.Compiler.Hoopl: showbLabelMapPrecWith :: (Int -> v -> Builder) -> Int -> LabelMap v -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbPointedWith :: (a -> Builder) -> Pointed t b a -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbUniqueMapPrecWith :: (Int -> v -> Builder) -> Int -> UniqueMap v -> Builder
+ Text.Show.Text.Control.Applicative.Trans: showbBackwardsPrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> Backwards f a -> Builder
+ Text.Show.Text.Control.Applicative.Trans: showbLiftPrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> Lift f a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbErrorTPrecWith :: (Show e, Show1 m) => (Int -> a -> Builder) -> Int -> ErrorT e m a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbExceptTPrecWith :: (Show e, Show1 m) => (Int -> a -> Builder) -> Int -> ExceptT e m a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbIdentityTPrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> IdentityT f a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbListTPrecWith :: Show1 m => (a -> Builder) -> Int -> ListT m a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbMaybeTPrecWith :: Show1 m => (Int -> a -> Builder) -> Int -> MaybeT m a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbWriterTLazyPrecWith :: (Show w, Show1 m) => (a -> Builder) -> Int -> WriterT w m a -> Builder
+ Text.Show.Text.Control.Monad.Trans: showbWriterTStrictPrecWith :: (Show w, Show1 m) => (a -> Builder) -> Int -> WriterT w m a -> Builder
+ Text.Show.Text.Data.Bifunctor: instance (Show (f a b), Show (g a b)) => Show (Product f g a b)
+ Text.Show.Text.Data.Bifunctor: instance (Show1 f, Show2 p, Show a) => Show1 (Tannen f p a)
+ Text.Show.Text.Data.Bifunctor: instance (Show1 f0, Show a0) => Show1 (Clown f0 a0)
+ Text.Show.Text.Data.Bifunctor: instance (Show1 f0, Show2 p0) => Show2 (Tannen f0 p0)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 f, Show2 g, Show a) => Show1 (Product f g a)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 f0, Show2 g0) => Show2 (Product f0 g0)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 p, Show a) => Show1 (Flip p a)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 p, Show a) => Show1 (WrappedBifunctor p a)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 p, Show1 f, Show1 g, Show a) => Show1 (Biff p f g a)
+ Text.Show.Text.Data.Bifunctor: instance (Show2 p0, Show1 f0, Show1 g0) => Show2 (Biff p0 f0 g0)
+ Text.Show.Text.Data.Bifunctor: instance Show (f (p a b)) => Show (Tannen f p a b)
+ Text.Show.Text.Data.Bifunctor: instance Show (f a) => Show (Clown f a b)
+ Text.Show.Text.Data.Bifunctor: instance Show (g b) => Show (Joker g a b)
+ Text.Show.Text.Data.Bifunctor: instance Show (p (f a) (g b)) => Show (Biff p f g a b)
+ Text.Show.Text.Data.Bifunctor: instance Show (p a a) => Show (Join p a)
+ Text.Show.Text.Data.Bifunctor: instance Show (p a b) => Show (WrappedBifunctor p a b)
+ Text.Show.Text.Data.Bifunctor: instance Show (p b a) => Show (Flip p a b)
+ Text.Show.Text.Data.Bifunctor: instance Show1 f0 => Show2 (Clown f0)
+ Text.Show.Text.Data.Bifunctor: instance Show1 g => Show1 (Joker g a)
+ Text.Show.Text.Data.Bifunctor: instance Show1 g0 => Show2 (Joker g0)
+ Text.Show.Text.Data.Bifunctor: instance Show2 p => Show1 (Join p)
+ Text.Show.Text.Data.Bifunctor: instance Show2 p0 => Show2 (Flip p0)
+ Text.Show.Text.Data.Bifunctor: instance Show2 p0 => Show2 (WrappedBifunctor p0)
+ Text.Show.Text.Data.Bifunctor: showbBiffPrec :: Show (p (f a) (g b)) => Int -> Biff p f g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbBiffPrecWith2 :: (Show2 p, Show1 f, Show1 g) => (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> Biff p f g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbClownPrec :: Show (f a) => Int -> Clown f a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbClownPrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> Clown f a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbFlipPrec :: Show (p b a) => Int -> Flip p a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbFlipPrecWith2 :: Show2 p => (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> Flip p a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbJoinPrec :: Show (p a a) => Int -> Join p a -> Builder
+ Text.Show.Text.Data.Bifunctor: showbJoinPrecWith :: Show2 p => (Int -> a -> Builder) -> Int -> Join p a -> Builder
+ Text.Show.Text.Data.Bifunctor: showbJokerPrec :: Show (g b) => Int -> Joker g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbJokerPrecWith :: Show1 g => (Int -> b -> Builder) -> Int -> Joker g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbProductPrec :: (Show (f a b), Show (g a b)) => Int -> Product f g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbProductPrecWith2 :: (Show2 f, Show2 g) => (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> Product f g a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbTannenPrec :: Show (f (p a b)) => Int -> Tannen f p a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbTannenPrecWith2 :: (Show1 f, Show2 p) => (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> Tannen f p a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbWrappedBifunctorPrec :: Show (p a b) => Int -> WrappedBifunctor p a b -> Builder
+ Text.Show.Text.Data.Bifunctor: showbWrappedBifunctorPrecWith2 :: Show2 p => (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> WrappedBifunctor p a b -> Builder
+ Text.Show.Text.Data.Binary: showbDecoderWith :: (a -> Builder) -> Decoder a -> Builder
+ Text.Show.Text.Data.Containers: instance Show2 Map
+ Text.Show.Text.Data.Containers: showbIntMapPrecWith :: (v -> Builder) -> Int -> IntMap v -> Builder
+ Text.Show.Text.Data.Containers: showbMapPrecWith2 :: (k -> Builder) -> (v -> Builder) -> Int -> Map k v -> Builder
+ Text.Show.Text.Data.Containers: showbSequencePrecWith :: (a -> Builder) -> Int -> Seq a -> Builder
+ Text.Show.Text.Data.Containers: showbSetPrecWith :: (a -> Builder) -> Int -> Set a -> Builder
+ Text.Show.Text.Data.Containers: showbTreePrecWith :: (a -> Builder) -> Int -> Tree a -> Builder
+ Text.Show.Text.Data.Containers: showbViewLPrecWith :: (a -> Builder) -> Int -> ViewL a -> Builder
+ Text.Show.Text.Data.Containers: showbViewRPrecWith :: (a -> Builder) -> Int -> ViewR a -> Builder
+ Text.Show.Text.Data.Functor.Trans: instance (Show1 f, Show1 g) => Show1 (Compose f g)
+ Text.Show.Text.Data.Functor.Trans: instance (Show1 f, Show1 g, Show a) => Show (Compose f g a)
+ Text.Show.Text.Data.Functor.Trans: instance Show2 Constant
+ Text.Show.Text.Data.Functor.Trans: showbComposePrecWith :: (Show1 f, Show1 g) => (Int -> a -> Builder) -> Int -> Compose f g a -> Builder
+ Text.Show.Text.Data.Functor.Trans: showbConstantPrecWith :: (Int -> a -> Builder) -> Int -> Constant a b -> Builder
+ Text.Show.Text.Data.Functor.Trans: showbProductPrecWith :: (Show1 f, Show1 g) => (Int -> a -> Builder) -> Int -> Product f g a -> Builder
+ Text.Show.Text.Data.Functor.Trans: showbReversePrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> Reverse f a -> Builder
+ Text.Show.Text.Data.Functor.Trans: showbSumPrecWith :: (Show1 f, Show1 g) => (Int -> a -> Builder) -> Int -> Sum f g a -> Builder
+ Text.Show.Text.Data.List.NonEmpty: showbNonEmptyPrecWith :: (Int -> a -> Builder) -> Int -> NonEmpty a -> Builder
+ Text.Show.Text.Data.Semigroup: instance Show a0 => Show1 (Arg a0)
+ Text.Show.Text.Data.Semigroup: instance Show2 Arg
+ Text.Show.Text.Data.Semigroup: showbArgPrecWith2 :: (Int -> a -> Builder) -> (Int -> b -> Builder) -> Int -> Arg a b -> Builder
+ Text.Show.Text.Data.Semigroup: showbFirstPrecWith :: (Int -> a -> Builder) -> Int -> First a -> Builder
+ Text.Show.Text.Data.Semigroup: showbLastPrecWith :: (Int -> a -> Builder) -> Int -> Last a -> Builder
+ Text.Show.Text.Data.Semigroup: showbMaxPrecWith :: (Int -> a -> Builder) -> Int -> Max a -> Builder
+ Text.Show.Text.Data.Semigroup: showbMinPrecWith :: (Int -> a -> Builder) -> Int -> Min a -> Builder
+ Text.Show.Text.Data.Semigroup: showbOptionPrecWith :: (Int -> a -> Builder) -> Int -> Option a -> Builder
+ Text.Show.Text.Data.Semigroup: showbWrappedMonoidPrecWith :: (Int -> m -> Builder) -> Int -> WrappedMonoid m -> Builder
+ Text.Show.Text.Data.Tagged: instance Show2 Tagged
+ Text.Show.Text.Data.Tagged: showbTaggedPrecWith :: (Int -> b -> Builder) -> Int -> Tagged s b -> Builder
+ Text.Show.Text.Data.UnorderedContainers: instance Show2 HashMap
+ Text.Show.Text.Data.UnorderedContainers: showbHashMapPrecWith2 :: (k -> Builder) -> (v -> Builder) -> Int -> HashMap k v -> Builder
+ Text.Show.Text.Data.UnorderedContainers: showbHashSetPrecWith :: (a -> Builder) -> Int -> HashSet a -> Builder
+ Text.Show.Text.Data.Vector: showbVectorGenericPrecWith :: Vector v a => (a -> Builder) -> Int -> v a -> Builder
+ Text.Show.Text.Data.Vector: showbVectorPrecWith :: (a -> Builder) -> Int -> Vector a -> Builder
Files
- CHANGELOG.md +28/−22
- LICENSE +30/−30
- README.md +27/−27
- Setup.hs +2/−2
- include/inline.h +13/−13
- src/Text/Show/Text/Compiler/Hoopl.hs +193/−195
- src/Text/Show/Text/Control/Applicative/Trans.hs +66/−60
- src/Text/Show/Text/Control/Monad/Trans.hs +180/−144
- src/Text/Show/Text/Data/Bifunctor.hs +220/−0
- src/Text/Show/Text/Data/Binary.hs +44/−42
- src/Text/Show/Text/Data/Containers.hs +194/−157
- src/Text/Show/Text/Data/Functor/Trans.hs +131/−120
- src/Text/Show/Text/Data/List/NonEmpty.hs +31/−38
- src/Text/Show/Text/Data/Semigroup.hs +107/−118
- src/Text/Show/Text/Data/String/UTF8.hs +0/−62
- src/Text/Show/Text/Data/Tagged.hs +42/−38
- src/Text/Show/Text/Data/Time.hs +233/−234
- src/Text/Show/Text/Data/UnorderedContainers.hs +76/−57
- src/Text/Show/Text/Data/Vector.hs +125/−107
- src/Text/Show/Text/Instances.hs +43/−43
- src/Text/Show/Text/Language/Haskell/TH.hs +517/−518
- src/Text/Show/Text/System/Console/Haskeline.hs +74/−73
- src/Text/Show/Text/System/Console/Terminfo.hs +58/−58
- src/Text/Show/Text/System/Directory.hs +30/−30
- src/Text/Show/Text/System/Locale.hs +30/−30
- src/Text/Show/Text/System/Posix.hs +79/−79
- src/Text/Show/Text/System/Random.hs +31/−31
- src/Text/Show/Text/System/Time.hs +76/−76
- src/Text/Show/Text/System/Win32.hs +125/−126
- src/Text/Show/Text/Text/PrettyPrint.hs +107/−109
- src/Text/Show/Text/Text/XHtml.hs +88/−89
- src/Text/Show/Text/Trace/Hpc.hs +106/−108
- src/Text/Show/Text/Utils.hs +31/−26
- tests/Instances/Compiler/Hoopl.hs +72/−72
- tests/Instances/Control/Applicative/Trans.hs +28/−28
- tests/Instances/Control/Monad/Trans.hs +35/−35
- tests/Instances/Data/Bifunctor.hs +42/−0
- tests/Instances/Data/Binary.hs +27/−27
- tests/Instances/Data/Containers.hs +26/−26
- tests/Instances/Data/Functor/Trans.hs +36/−36
- tests/Instances/Data/List/NonEmpty.hs +22/−22
- tests/Instances/Data/Semigroup.hs +32/−32
- tests/Instances/Data/String/UTF8.hs +0/−22
- tests/Instances/Data/Tagged.hs +19/−19
- tests/Instances/Language/Haskell/TH.hs +610/−620
- tests/Instances/Miscellaneous.hs +89/−89
- tests/Instances/System/Console/Haskeline.hs +34/−34
- tests/Instances/System/Console/Terminfo.hs +40/−40
- tests/Instances/System/Directory.hs +31/−31
- tests/Instances/System/Locale.hs +23/−23
- tests/Instances/System/Posix.hs +56/−56
- tests/Instances/System/Random.hs +22/−22
- tests/Instances/System/Win32.hs +109/−109
- tests/Instances/Text/PrettyPrint.hs +48/−48
- tests/Instances/Text/XHtml.hs +32/−32
- tests/Instances/Trace/Hpc.hs +63/−63
- tests/Instances/Utils.hs +16/−16
- tests/Spec/Compiler/HooplSpec.hs +50/−40
- tests/Spec/Control/Applicative/TransSpec.hs +33/−31
- tests/Spec/Control/Monad/TransSpec.hs +49/−42
- tests/Spec/Data/BifunctorSpec.hs +51/−0
- tests/Spec/Data/BinarySpec.hs +29/−29
- tests/Spec/Data/ContainersSpec.hs +50/−42
- tests/Spec/Data/Functor/TransSpec.hs +42/−37
- tests/Spec/Data/List/NonEmptySpec.hs +31/−29
- tests/Spec/Data/SemigroupSpec.hs +56/−35
- tests/Spec/Data/String/UTF8Spec.hs +0/−35
- tests/Spec/Data/TaggedSpec.hs +29/−29
- tests/Spec/Data/TimeSpec.hs +48/−39
- tests/Spec/Data/UnorderedContainersSpec.hs +32/−30
- tests/Spec/Language/Haskell/THSpec.hs +187/−99
- tests/Spec/System/Console/HaskelineSpec.hs +41/−36
- tests/Spec/System/Console/TerminfoSpec.hs +44/−43
- tests/Spec/System/DirectorySpec.hs +42/−42
- tests/Spec/System/LocaleSpec.hs +29/−29
- tests/Spec/System/PosixSpec.hs +52/−48
- tests/Spec/System/RandomSpec.hs +29/−29
- tests/Spec/System/TimeSpec.hs +37/−32
- tests/Spec/System/Win32Spec.hs +63/−54
- tests/Spec/Text/PrettyPrintSpec.hs +63/−45
- tests/Spec/Text/XHtmlSpec.hs +38/−33
- tests/Spec/Trace/HpcSpec.hs +44/−37
- tests/Spec/Utils.hs +62/−22
- text-show-instances.cabal +245/−243
CHANGELOG.md view
@@ -1,23 +1,29 @@-# 0.4 -* Allow building with `text-show-0.8` -* Modules which were previously exported only if using a recent-enough version of GHC/`base` (e.g., `Text.Show.Text.System.Win32`) are now always exposed. If the functionality that the module provides is not available on a given version of GHC/`base`, the module will not expose anything. -* Change test-suite to use `hspec`, allowing for it to be built on GHC 7.0 and 7.2 - -### 0.3.0.1 -* Fixed tests on Windows - -# 0.3 -* Added `showbArgPrec` (and corresponding `Show` and `Show1` instances) to `Text.Show.Text.Data.Semigroup` -* Added `Show1` instances for data types in `Text.Show.Text.Data.List.NonEmpty` and `Text.Show.Text.Data.Semigroup` -* Added `showbDoc` (and corresponding `Show` instance) to `Text.Show.Text.Language.Haskell.TH` -* Renamed `showbDoc` in `Text.Show.Text.Text.PrettyPrint` to `renderB` - -# 0.2 -* Exposed `showbKindPrec` and `showbPredPrec` with later versions of Template Haskell -* Added `renderStyleB` to `Text.Show.Text.Text.PrettyPrint` (for `time-1.5` and later) -* Added `showbTimeLocalePrec` to `Text.Show.Text.Data.Time` -* Added instances for the `binary`, `haskeline`, `hoopl`, `terminfo`, and `utf8-string` libraries -* Removed `transformers-four` flag - -# 0.1 +# 1+* Allow building with `text-show-1`. Also changed the monomorphic functions to match the naming conventions introduced in `text-show-1`.+* Added instances for the `bifunctors` library+* Removed `utf8-string` instance, since it wasn't as useful as I had imagined+* Revamped test suite++# 0.4+* Allow building with `text-show-0.8`+* Modules which were previously exported only if using a recent-enough version of GHC/`base` (e.g., `Text.Show.Text.System.Win32`) are now always exposed. If the functionality that the module provides is not available on a given version of GHC/`base`, the module will not expose anything.+* Change test-suite to use `hspec`, allowing for it to be built on GHC 7.0 and 7.2++### 0.3.0.1+* Fixed tests on Windows++# 0.3+* Added `showbArgPrec` (and corresponding `Show` and `Show1` instances) to `Text.Show.Text.Data.Semigroup`+* Added `Show1` instances for data types in `Text.Show.Text.Data.List.NonEmpty` and `Text.Show.Text.Data.Semigroup`+* Added `showbDoc` (and corresponding `Show` instance) to `Text.Show.Text.Language.Haskell.TH`+* Renamed `showbDoc` in `Text.Show.Text.Text.PrettyPrint` to `renderB`++# 0.2+* Exposed `showbKindPrec` and `showbPredPrec` with later versions of Template Haskell+* Added `renderStyleB` to `Text.Show.Text.Text.PrettyPrint` (for `time-1.5` and later)+* Added `showbTimeLocalePrec` to `Text.Show.Text.Data.Time`+* Added instances for the `binary`, `haskeline`, `hoopl`, `terminfo`, and `utf8-string` libraries+* Removed `transformers-four` flag++# 0.1 * Initial commit
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2014, Ryan Scott - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Ryan Scott nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2014, Ryan Scott++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Ryan Scott nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md view
@@ -1,28 +1,28 @@-# `text-show-instances` [](http://hackage.haskell.org/package/text-show-instances) [](https://travis-ci.org/RyanGlScott/text-show-instances) - -`text-show-instances` is a supplemental library to [`text-show`](https://github.com/RyanGlScott/text-show) that provides additional `Show` instances for data types in common Haskell libraries and GHC dependencies that are not encompassed by `text-show`. Currently, `text-show-instances` covers these libraries: - -* [`binary`](http://hackage.haskell.org/package/binary) -* [`containers`](http://hackage.haskell.org/package/containers) -* [`directory`](http://hackage.haskell.org/package/directory) -* [`haskeline`](http://hackage.haskell.org/package/haskeline) -* [`hoopl`](http://hackage.haskell.org/package/hoopl) -* [`hpc`](http://hackage.haskell.org/package/hpc) -* [`old-locale`](http://hackage.haskell.org/package/old-locale) -* [`old-time`](http://hackage.haskell.org/package/old-time) -* [`pretty`](http://hackage.haskell.org/package/pretty) -* [`random`](http://hackage.haskell.org/package/random) -* [`semigroups`](http://hackage.haskell.org/package/semigroups) -* [`tagged`](http://hackage.haskell.org/package/tagged) -* [`template-haskell`](http://hackage.haskell.org/package/template-haskell) -* [`terminfo`](http://hackage.haskell.org/package/terminfo) -* [`time`](http://hackage.haskell.org/package/time) -* [`transformers`](http://hackage.haskell.org/package/transformers) -* [`unix`](http://hackage.haskell.org/package/unix) -* [`unordered-containers`](http://hackage.haskell.org/package/unordered-containers) -* [`utf8-string`](http://hackage.haskell.org/package/utf8-string) -* [`vector`](http://hackage.haskell.org/package/vector) -* [`Win32`](http://hackage.haskell.org/package/Win32) -* [`xhtml`](http://hackage.haskell.org/package/xhtml) - +# `text-show-instances` [](http://hackage.haskell.org/package/text-show-instances) [](https://travis-ci.org/RyanGlScott/text-show-instances)++`text-show-instances` is a supplemental library to [`text-show`](https://github.com/RyanGlScott/text-show) that provides additional `Show` instances for data types in common Haskell libraries and GHC dependencies that are not encompassed by `text-show`. Currently, `text-show-instances` covers these libraries:++* [`binary`](http://hackage.haskell.org/package/binary)+* [`containers`](http://hackage.haskell.org/package/containers)+* [`directory`](http://hackage.haskell.org/package/directory)+* [`haskeline`](http://hackage.haskell.org/package/haskeline)+* [`hoopl`](http://hackage.haskell.org/package/hoopl)+* [`hpc`](http://hackage.haskell.org/package/hpc)+* [`old-locale`](http://hackage.haskell.org/package/old-locale)+* [`old-time`](http://hackage.haskell.org/package/old-time)+* [`pretty`](http://hackage.haskell.org/package/pretty)+* [`random`](http://hackage.haskell.org/package/random)+* [`semigroups`](http://hackage.haskell.org/package/semigroups)+* [`tagged`](http://hackage.haskell.org/package/tagged)+* [`template-haskell`](http://hackage.haskell.org/package/template-haskell)+* [`terminfo`](http://hackage.haskell.org/package/terminfo)+* [`time`](http://hackage.haskell.org/package/time)+* [`transformers`](http://hackage.haskell.org/package/transformers)+* [`unix`](http://hackage.haskell.org/package/unix)+* [`unordered-containers`](http://hackage.haskell.org/package/unordered-containers)+* [`utf8-string`](http://hackage.haskell.org/package/utf8-string)+* [`vector`](http://hackage.haskell.org/package/vector)+* [`Win32`](http://hackage.haskell.org/package/Win32)+* [`xhtml`](http://hackage.haskell.org/package/xhtml)+ One can use these instances by importing `Text.Show.Text.Instances`. Alternatively, there are monomorphic versions of the `showb` function available in the other submodules of `Text.Show.Text`.
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple -main = defaultMain +import Distribution.Simple+main = defaultMain
include/inline.h view
@@ -1,13 +1,13 @@-#ifndef INLINE_H -#define INLINE_H - -#define OPEN_PRAGMA {-# -#define CLOSE_PRAGMA #-} - -#if __GLASGOW_HASKELL__ >= 702 -#define INLINE_INST_FUN(F) OPEN_PRAGMA INLINE F CLOSE_PRAGMA -#else -#define INLINE_INST_FUN(F) -#endif - -#endif +#ifndef INLINE_H+#define INLINE_H++#define OPEN_PRAGMA {-#+#define CLOSE_PRAGMA #-}++#if __GLASGOW_HASKELL__ >= 702+#define INLINE_INST_FUN(F) OPEN_PRAGMA INLINE F CLOSE_PRAGMA+#else+#define INLINE_INST_FUN(F)+#endif++#endif
src/Text/Show/Text/Compiler/Hoopl.hs view
@@ -1,195 +1,193 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Compiler.Hoopl -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @hoopl@ library. - -/Since: 0.2/ --} -module Text.Show.Text.Compiler.Hoopl ( - showbLabel - , showbLabelMapPrec - , showbLabelSetPrec - , showbPointed - , showbUnique - , showbUniqueMapPrec - , showbUniqueSetPrec - , showbDominatorNode - , showbDominatorTree - , showbDPath - ) where - -import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed(..), - Unique, UniqueMap, UniqueSet) -#if MIN_VERSION_hoopl(3,9,0) -import Compiler.Hoopl.Internals (lblToUnique) -#else -import Compiler.Hoopl.GHC (lblToUnique, uniqueToInt) -#endif -import Compiler.Hoopl.Passes.Dominator (DominatorNode(..), DominatorTree(..), DPath(..)) - -import Data.Monoid.Compat - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showb, showbPrec), Show1(showbPrec1), Builder) -import Text.Show.Text.Data.Containers () -import Text.Show.Text.Data.Integral (showbIntPrec) -import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec) -import Text.Show.Text.Utils (s) - -#include "inline.h" - --- | Convert a 'Label' to a 'Builder'. --- --- /Since: 0.2/ -showbLabel :: Label -> Builder -showbLabel l = s 'L' <> showbUnique (lblToUnique l) -{-# INLINE showbLabel #-} - --- | Convert a 'LabelMap' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbLabelMapPrec :: Show v => Int -> LabelMap v -> Builder -showbLabelMapPrec = showbPrec -{-# INLINE showbLabelMapPrec #-} - --- | Convert a 'LabelSet' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbLabelSetPrec :: Int -> LabelSet -> Builder -showbLabelSetPrec = showbPrec -{-# INLINE showbLabelSetPrec #-} - --- | Convert a 'Pointed' value to a 'Builder'. --- --- /Since: 0.2/ -showbPointed :: Show a => Pointed t b a -> Builder -showbPointed Bot = "_|_" -showbPointed Top = s 'T' -showbPointed (PElem a) = showb a -{-# INLINE showbPointed #-} - --- | Convert a 'Unique' value to a 'Builder'. --- --- /Since: 0.2/ -showbUnique :: Unique -> Builder -#if MIN_VERSION_hoopl(3,9,0) -showbUnique = showbIntPrec 0 -#else -showbUnique = showbIntPrec 0 . uniqueToInt -#endif -{-# INLINE showbUnique #-} - --- | Convert a 'UniqueMap' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbUniqueMapPrec :: Show v => Int -> UniqueMap v -> Builder -showbUniqueMapPrec = showbPrec -{-# INLINE showbUniqueMapPrec #-} - --- | Convert a 'UniqueSet' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbUniqueSetPrec :: Int -> UniqueSet -> Builder -showbUniqueSetPrec = showbPrec -{-# INLINE showbUniqueSetPrec #-} - --- | Convert a 'DominatorNode' to a 'Builder'. --- --- /Since: 0.2/ -showbDominatorNode :: DominatorNode -> Builder -showbDominatorNode Entry = "entryNode" -showbDominatorNode (Labelled l) = showbLabel l -{-# INLINE showbDominatorNode #-} - --- | Convert a 'DominatorTree' to a 'Builder'. --- --- /Since: 0.2/ -showbDominatorTree :: DominatorTree -> Builder -showbDominatorTree t = mconcat $ "digraph {\n" : dot t ["}\n"] - where - dot :: DominatorTree -> [Builder] -> [Builder] - dot (Dominates root trees) = - (dotnode root :) . outedges trees . flip (foldl subtree) trees - where - outedges :: [DominatorTree] -> [Builder] -> [Builder] - outedges [] = id - outedges (Dominates n _ : ts) = - \bs -> " " - : showbDominatorNode root - : " -> " - : showbDominatorNode n - : s '\n' - : outedges ts bs - - dotnode :: DominatorNode -> Builder - dotnode Entry = " entryNode [shape=plaintext, label=\"entry\"]\n" - dotnode (Labelled l) = " " <> showbLabel l <> s '\n' - - subtree :: [Builder] -> DominatorTree -> [Builder] - subtree = flip dot - --- | Convert a 'DPath' to a 'Builder'. --- --- /Since: 0.2/ -showbDPath :: DPath -> Builder -showbDPath (DPath ls) = mconcat $ foldr (\l path ->showbLabel l <> " -> " : path) - ["entry"] - ls -{-# INLINE showbDPath #-} - -instance Show Label where - showb = showbLabel - INLINE_INST_FUN(showb) - -$(deriveShowPragmas defaultInlineShowbPrec ''LabelMap) - -instance Show1 LabelMap where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -$(deriveShowPragmas defaultInlineShowbPrec ''LabelSet) - -instance Show a => Show (Pointed t b a) where - showb = showbPointed - INLINE_INST_FUN(showb) - -instance Show1 (Pointed t b) where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -#if !(MIN_VERSION_hoopl(3,9,0)) -instance Show Unique where - showb = showbUnique - INLINE_INST_FUN(showb) -#endif - -$(deriveShowPragmas defaultInlineShowbPrec ''UniqueMap) - -instance Show1 UniqueMap where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -$(deriveShowPragmas defaultInlineShowbPrec ''UniqueSet) - -instance Show DominatorNode where - showb = showbDominatorNode - INLINE_INST_FUN(showb) - -instance Show DominatorTree where - showb = showbDominatorTree - INLINE_INST_FUN(showb) - -instance Show DPath where - showb = showbDPath - INLINE_INST_FUN(showb) +{-# LANGUAGE CPP #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Compiler.Hoopl+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @hoopl@ library.++/Since: 0.2/+-}+module Text.Show.Text.Compiler.Hoopl (+ showbLabel+ , showbLabelMapPrecWith+ , showbLabelSetPrec+ , showbPointedWith+ , showbUnique+ , showbUniqueMapPrecWith+ , showbUniqueSetPrec+ , showbDominatorNode+ , showbDominatorTree+ , showbDPath+ ) where++import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed(..),+ Unique, UniqueMap, UniqueSet)+#if MIN_VERSION_hoopl(3,9,0)+import Compiler.Hoopl.Internals (lblToUnique)+#else+import Compiler.Hoopl.GHC (lblToUnique, uniqueToInt)+#endif+import Compiler.Hoopl.Passes.Dominator (DominatorNode(..), DominatorTree(..), DPath(..))++import Data.Monoid.Compat++import Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Show1(..), Show2(..),+ Builder, singleton)+import Text.Show.Text.Data.Containers ()+import Text.Show.Text.Data.Integral (showbIntPrec)+import Text.Show.Text.TH (deriveShow, deriveShow1)++#include "inline.h"++-- | Convert a 'Label' to a 'Builder'.+--+-- /Since: 0.2/+showbLabel :: Label -> Builder+showbLabel l = singleton 'L' <> showbUnique (lblToUnique l)+{-# INLINE showbLabel #-}++-- | Convert a 'LabelMap' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbLabelMapPrecWith :: (Int -> v -> Builder) -> Int -> LabelMap v -> Builder+showbLabelMapPrecWith = showbPrecWith+{-# INLINE showbLabelMapPrecWith #-}++-- | Convert a 'LabelSet' to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbLabelSetPrec :: Int -> LabelSet -> Builder+showbLabelSetPrec = showbPrec+{-# INLINE showbLabelSetPrec #-}++-- | Convert a 'Pointed' value to a 'Builder' with the given show function.+--+-- /Since: 1/+showbPointedWith :: (a -> Builder) -> Pointed t b a -> Builder+showbPointedWith _ Bot = "_|_"+showbPointedWith _ Top = singleton 'T'+showbPointedWith sp (PElem a) = sp a+{-# INLINE showbPointedWith #-}++-- | Convert a 'Unique' value to a 'Builder'.+--+-- /Since: 0.2/+showbUnique :: Unique -> Builder+#if MIN_VERSION_hoopl(3,9,0)+showbUnique = showbIntPrec 0+#else+showbUnique = showbIntPrec 0 . uniqueToInt+#endif+{-# INLINE showbUnique #-}++-- | Convert a 'UniqueMap' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbUniqueMapPrecWith :: (Int -> v -> Builder) -> Int -> UniqueMap v -> Builder+showbUniqueMapPrecWith = showbPrecWith+{-# INLINE showbUniqueMapPrecWith #-}++-- | Convert a 'UniqueSet' to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbUniqueSetPrec :: Int -> UniqueSet -> Builder+showbUniqueSetPrec = showbPrec+{-# INLINE showbUniqueSetPrec #-}++-- | Convert a 'DominatorNode' to a 'Builder'.+--+-- /Since: 0.2/+showbDominatorNode :: DominatorNode -> Builder+showbDominatorNode Entry = "entryNode"+showbDominatorNode (Labelled l) = showbLabel l+{-# INLINE showbDominatorNode #-}++-- | Convert a 'DominatorTree' to a 'Builder'.+--+-- /Since: 0.2/+showbDominatorTree :: DominatorTree -> Builder+showbDominatorTree t = mconcat $ "digraph {\n" : dot t ["}\n"]+ where+ dot :: DominatorTree -> [Builder] -> [Builder]+ dot (Dominates root trees) =+ (dotnode root :) . outedges trees . flip (foldl subtree) trees+ where+ outedges :: [DominatorTree] -> [Builder] -> [Builder]+ outedges [] = id+ outedges (Dominates n _ : ts) =+ \bs -> " "+ : showbDominatorNode root+ : " -> "+ : showbDominatorNode n+ : singleton '\n'+ : outedges ts bs++ dotnode :: DominatorNode -> Builder+ dotnode Entry = " entryNode [shape=plaintext, label=\"entry\"]\n"+ dotnode (Labelled l) = " " <> showbLabel l <> singleton '\n'++ subtree :: [Builder] -> DominatorTree -> [Builder]+ subtree = flip dot++-- | Convert a 'DPath' to a 'Builder'.+--+-- /Since: 0.2/+showbDPath :: DPath -> Builder+showbDPath (DPath ls) = mconcat $ foldr (\l path ->showbLabel l <> " -> " : path)+ ["entry"]+ ls+{-# INLINE showbDPath #-}++instance Show Label where+ showb = showbLabel+ INLINE_INST_FUN(showb)++$(deriveShow ''LabelMap)+$(deriveShow1 ''LabelMap)++$(deriveShow ''LabelSet)++instance Show a => Show (Pointed t b a) where+ showbPrec = showbPrecWith showbPrec+ INLINE_INST_FUN(showbPrec)++instance Show1 (Pointed t b) where+ showbPrecWith sp _ = showbPointedWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++instance Show2 (Pointed t) where+ showbPrecWith2 _ = showbPrecWith+ INLINE_INST_FUN(showbPrecWith2)++#if !(MIN_VERSION_hoopl(3,9,0))+instance Show Unique where+ showb = showbUnique+ INLINE_INST_FUN(showb)+#endif++$(deriveShow ''UniqueMap)+$(deriveShow1 ''UniqueMap)++$(deriveShow ''UniqueSet)++instance Show DominatorNode where+ showb = showbDominatorNode+ INLINE_INST_FUN(showb)++instance Show DominatorTree where+ showb = showbDominatorTree+ INLINE_INST_FUN(showb)++instance Show DPath where+ showb = showbDPath+ INLINE_INST_FUN(showb)
src/Text/Show/Text/Control/Applicative/Trans.hs view
@@ -1,60 +1,66 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Control.Applicative.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for applicative functor transformers. - -/Since: 0.1/ --} -module Text.Show.Text.Control.Applicative.Trans ( - showbBackwardsPrec - , showbLiftPrec - ) where - -import Control.Applicative.Backwards (Backwards(..)) -import Control.Applicative.Lift (Lift(..)) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder, - showbUnary, showbUnary1) - -#include "inline.h" - --- | Convert a 'Backwards' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbBackwardsPrec :: (Show1 f, Show a) => Int -> Backwards f a -> Builder -showbBackwardsPrec p (Backwards x) = showbUnary1 "Backwards" p x -{-# INLINE showbBackwardsPrec #-} - --- | Convert a 'Lift' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbLiftPrec :: (Show1 f, Show a) => Int -> Lift f a -> Builder -showbLiftPrec p (Pure x) = showbUnary "Pure" p x -showbLiftPrec p (Other y) = showbUnary1 "Other" p y -{-# INLINE showbLiftPrec #-} - -instance (Show1 f, Show a) => Show (Backwards f a) where - showbPrec = showbBackwardsPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 f => Show1 (Backwards f) where - showbPrec1 = showbBackwardsPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 f, Show a) => Show (Lift f a) where - showbPrec = showbLiftPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 f => Show1 (Lift f) where - showbPrec1 = showbLiftPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Control.Applicative.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for applicative functor transformers.++/Since: 0.1/+-}+module Text.Show.Text.Control.Applicative.Trans (+ showbBackwardsPrecWith+ , showbLiftPrecWith+ ) where++import Control.Applicative.Backwards (Backwards(..))+import Control.Applicative.Lift (Lift(..))++import Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Show1(..), Builder,+ showbPrec1, showbUnaryWith)++#include "inline.h"++-- | Convert a 'Backwards' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbBackwardsPrecWith :: Show1 f+ => (Int -> a -> Builder)+ -> Int -> Backwards f a -> Builder+showbBackwardsPrecWith sp p (Backwards x)+ = showbUnaryWith (showbPrecWith sp) "Backwards" p x+{-# INLINE showbBackwardsPrecWith #-}++-- | Convert a 'Lift' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbLiftPrecWith :: Show1 f+ => (Int -> 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 #-}++instance (Show1 f, Show a) => Show (Backwards f a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 f => Show1 (Backwards f) where+ showbPrecWith = showbBackwardsPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 f, Show a) => Show (Lift f a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 f => Show1 (Lift f) where+ showbPrecWith = showbLiftPrecWith+ INLINE_INST_FUN(showbPrecWith)
src/Text/Show/Text/Control/Monad/Trans.hs view
@@ -1,144 +1,180 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans -fno-warn-warnings-deprecations #-} -{-| -Module: Text.Show.Text.Control.Monad.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for monad transformers. - -/Since: 0.1/ --} -module Text.Show.Text.Control.Monad.Trans ( - showbErrorTPrec - , showbExceptTPrec - , showbIdentityTPrec - , showbListTPrec - , showbMaybeTPrec - , showbWriterTLazyPrec - , showbWriterTStrictPrec - ) where - -import Control.Monad.Trans.Error (ErrorT(..)) -import Control.Monad.Trans.Except (ExceptT(..)) -import Control.Monad.Trans.Identity (IdentityT(..)) -import Control.Monad.Trans.List (ListT(..)) -import Control.Monad.Trans.Maybe (MaybeT(..)) -import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT(..)) -import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT(..)) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), - Builder, showbUnary1) - -#include "inline.h" - --- | Convert an 'ErrorT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbErrorTPrec :: (Show e, Show1 m, Show a) => Int -> ErrorT e m a -> Builder -showbErrorTPrec p (ErrorT m) = showbUnary1 "ErrorT" p m -{-# INLINE showbErrorTPrec #-} - --- | Convert an 'ExceptT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbExceptTPrec :: (Show e, Show1 m, Show a) => Int -> ExceptT e m a -> Builder -showbExceptTPrec p (ExceptT m) = showbUnary1 "ExceptT" p m -{-# INLINE showbExceptTPrec #-} - --- | Convert an 'IdentityT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbIdentityTPrec :: (Show1 f, Show a) => Int -> IdentityT f a -> Builder -showbIdentityTPrec p (IdentityT m) = showbUnary1 "IdentityT" p m -{-# INLINE showbIdentityTPrec #-} - --- | Convert a 'ListT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbListTPrec :: (Show1 m, Show a) => Int -> ListT m a -> Builder -showbListTPrec p (ListT m) = showbUnary1 "ListT" p m -{-# INLINE showbListTPrec #-} - --- | Convert a 'MaybeT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMaybeTPrec :: (Show1 m, Show a) => Int -> MaybeT m a -> Builder -showbMaybeTPrec p (MaybeT m) = showbUnary1 "MaybeT" p m -{-# INLINE showbMaybeTPrec #-} - --- | Convert a lazy 'WL.WriterT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbWriterTLazyPrec :: (Show w, Show1 m, Show a) => Int -> WL.WriterT w m a -> Builder -showbWriterTLazyPrec p (WL.WriterT m) = showbUnary1 "WriterT" p m -{-# INLINE showbWriterTLazyPrec #-} - --- | Convert a strict 'WS.WriterT' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbWriterTStrictPrec :: (Show w, Show1 m, Show a) => Int -> WS.WriterT w m a -> Builder -showbWriterTStrictPrec p (WS.WriterT m) = showbUnary1 "WriterT" p m -{-# INLINE showbWriterTStrictPrec #-} - -instance (Show e, Show1 m, Show a) => Show (ErrorT e m a) where - showbPrec = showbErrorTPrec - INLINE_INST_FUN(showbPrec) - -instance (Show e, Show1 m) => Show1 (ErrorT e m) where - showbPrec1 = showbErrorTPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show e, Show1 m, Show a) => Show (ExceptT e m a) where - showbPrec = showbExceptTPrec - INLINE_INST_FUN(showbPrec) - -instance (Show e, Show1 m) => Show1 (ExceptT e m) where - showbPrec1 = showbExceptTPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 f, Show a) => Show (IdentityT f a) where - showbPrec = showbIdentityTPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 f => Show1 (IdentityT f) where - showbPrec1 = showbIdentityTPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 m, Show a) => Show (ListT m a) where - showbPrec = showbListTPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 m => Show1 (ListT m) where - showbPrec1 = showbListTPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 m, Show a) => Show (MaybeT m a) where - showbPrec = showbMaybeTPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 m => Show1 (MaybeT m) where - showbPrec1 = showbMaybeTPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show w, Show1 m, Show a) => Show (WL.WriterT w m a) where - showbPrec = showbWriterTLazyPrec - INLINE_INST_FUN(showbPrec) - -instance (Show w, Show1 m) => Show1 (WL.WriterT w m) where - showbPrec1 = showbWriterTLazyPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show w, Show1 m, Show a) => Show (WS.WriterT w m a) where - showbPrec = showbWriterTStrictPrec - INLINE_INST_FUN(showbPrec) - -instance (Show w, Show1 m) => Show1 (WS.WriterT w m) where - showbPrec1 = showbWriterTStrictPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans -fno-warn-warnings-deprecations #-}+{-|+Module: Text.Show.Text.Control.Monad.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for monad transformers.++/Since: 0.1/+-}+module Text.Show.Text.Control.Monad.Trans (+ showbErrorTPrecWith+ , showbExceptTPrecWith+ , showbIdentityTPrecWith+ , showbListTPrec+ , showbListTPrecWith+ , showbMaybeTPrecWith+ , showbWriterTLazyPrecWith+ , showbWriterTStrictPrecWith+ ) where++import Control.Monad.Trans.Error (ErrorT(..))+import Control.Monad.Trans.Except (ExceptT(..))+import Control.Monad.Trans.Identity (IdentityT(..))+import Control.Monad.Trans.List (ListT(..))+import Control.Monad.Trans.Maybe (MaybeT(..))+import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT(..))+import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT(..))++import Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Show1(..), Builder,+ showbPrec1, showbUnaryWith)+import Text.Show.Text.Data.Tuple (showb2TupleWith2)++#include "inline.h"++-- | Convert an 'ErrorT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbErrorTPrecWith :: (Show e, Show1 m)+ => (Int -> a -> Builder)+ -> Int -> ErrorT e m a -> Builder+showbErrorTPrecWith sp p (ErrorT m) =+ showbUnaryWith (showbPrecWith (showbPrecWith sp)) "ErrorT" p m+{-# INLINE showbErrorTPrecWith #-}++-- | Convert an 'ExceptT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbExceptTPrecWith :: (Show e, Show1 m)+ => (Int -> a -> Builder)+ -> Int -> ExceptT e m a -> Builder+showbExceptTPrecWith sp p (ExceptT m) =+ showbUnaryWith (showbPrecWith (showbPrecWith sp)) "ExceptT" p m+{-# INLINE showbExceptTPrecWith #-}++-- | Convert an 'IdentityT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbIdentityTPrecWith :: Show1 f+ => (Int -> 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: 0.1/+showbListTPrec :: (Show1 m, Show a) => Int -> ListT m a -> Builder+showbListTPrec p (ListT m) = showbUnaryWith (showbPrecWith showbPrec) "ListT" p m+{-# INLINE showbListTPrec #-}++-- | Convert a 'ListT' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbListTPrecWith :: Show1 m+ => (a -> Builder)+ -> Int -> ListT m a -> Builder+showbListTPrecWith sp p (ListT m) =+ showbUnaryWith (showbPrecWith (showbPrecWith (const sp))) "ListT" p m+{-# INLINE showbListTPrecWith #-}++-- | Convert a 'MaybeT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbMaybeTPrecWith :: Show1 m+ => (Int -> a -> Builder)+ -> Int -> MaybeT m a -> Builder+showbMaybeTPrecWith sp p (MaybeT m) =+ showbUnaryWith (showbPrecWith (showbPrecWith sp)) "MaybeT" p m+{-# INLINE showbMaybeTPrecWith #-}++-- | Convert a lazy 'WL.WriterT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbWriterTLazyPrecWith :: (Show w, Show1 m)+ => (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 #-}++-- | Convert a strict 'WS.WriterT' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbWriterTStrictPrecWith :: (Show w, Show1 m)+ => (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 #-}++instance (Show e, Show1 m, Show a) => Show (ErrorT e m a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show e, Show1 m) => Show1 (ErrorT e m) where+ showbPrecWith = showbErrorTPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show e, Show1 m, Show a) => Show (ExceptT e m a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show e, Show1 m) => Show1 (ExceptT e m) where+ showbPrecWith = showbExceptTPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 f, Show a) => Show (IdentityT f a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 f => Show1 (IdentityT f) where+ showbPrecWith = showbIdentityTPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 m, Show a) => Show (ListT m a) where+ showbPrec = showbListTPrec+ INLINE_INST_FUN(showbPrec)++instance Show1 m => Show1 (ListT m) where+ showbPrecWith sp = showbListTPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 m, Show a) => Show (MaybeT m a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 m => Show1 (MaybeT m) where+ showbPrecWith = showbMaybeTPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show w, Show1 m, Show a) => Show (WL.WriterT w m a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show w, Show1 m) => Show1 (WL.WriterT w m) where+ showbPrecWith sp = showbWriterTLazyPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++instance (Show w, Show1 m, Show a) => Show (WS.WriterT w m a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show w, Show1 m) => Show1 (WS.WriterT w m) where+ showbPrecWith sp = showbWriterTStrictPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)
+ src/Text/Show/Text/Data/Bifunctor.hs view
@@ -0,0 +1,220 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module: Text.Show.Text.Data.Bifunctor+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @bifunctors@ library.++/Since: 1/+-}+module Text.Show.Text.Data.Bifunctor (+ showbBiffPrec+ , showbBiffPrecWith2+ , showbClownPrec+ , showbClownPrecWith+ , showbFlipPrec+ , showbFlipPrecWith2+ , showbJoinPrec+ , showbJoinPrecWith+ , showbJokerPrec+ , showbJokerPrecWith+ , showbProductPrec+ , showbProductPrecWith2+ , showbTannenPrec+ , showbTannenPrecWith2+ , showbWrappedBifunctorPrec+ , showbWrappedBifunctorPrecWith2+ ) where++import Data.Bifunctor.Biff (Biff)+import Data.Bifunctor.Clown (Clown)+import Data.Bifunctor.Flip (Flip)+import Data.Bifunctor.Join (Join(..))+import Data.Bifunctor.Joker (Joker)+import Data.Bifunctor.Product (Product)+import Data.Bifunctor.Tannen (Tannen)+import Data.Bifunctor.Wrapped (WrappedBifunctor)++import Prelude hiding (Show)++import Text.Show.Text (Show(..), Show1(..), Show2(..), Builder)+import Text.Show.Text.TH (deriveShow1, deriveShow2, mkShowbPrec, mkShowbPrecWith)++-- | Convert a 'Biff' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbBiffPrec :: Show (p (f a) (g b)) => Int -> Biff p f g a b -> Builder+showbBiffPrec = showbPrec+{-# INLINE showbBiffPrec #-}++-- | Convert a 'Biff' value to a 'Builder' with the given show functions and precedence.+--+-- /Since: 1/+showbBiffPrecWith2 :: (Show2 p, Show1 f, Show1 g)+ => (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> Biff p f g a b -> Builder+showbBiffPrecWith2 = showbPrecWith2+{-# INLINE showbBiffPrecWith2 #-}++-- | Convert a 'Clown' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbClownPrec :: Show (f a) => Int -> Clown f a b -> Builder+showbClownPrec = showbPrec+{-# INLINE showbClownPrec #-}++-- | Convert a 'Clown' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbClownPrecWith :: Show1 f => (Int -> a -> Builder) -> Int -> Clown f a b -> Builder+showbClownPrecWith sp = showbPrecWith2 sp undefined+{-# INLINE showbClownPrecWith #-}++-- | Convert a 'Flip' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbFlipPrec :: Show (p b a) => Int -> Flip p a b -> Builder+showbFlipPrec = showbPrec+{-# INLINE showbFlipPrec #-}++-- | Convert a 'Flip' value to a 'Builder' with the given show functions and precedence.+--+-- /Since: 1/+showbFlipPrecWith2 :: Show2 p+ => (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> Flip p a b -> Builder+showbFlipPrecWith2 = showbPrecWith2+{-# INLINE showbFlipPrecWith2 #-}++-- | Convert a 'Join' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbJoinPrec :: Show (p a a) => Int -> Join p a -> Builder+showbJoinPrec = showbPrec+{-# INLINE showbJoinPrec #-}++-- | Convert a 'Join' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbJoinPrecWith :: Show2 p => (Int -> a -> Builder) -> Int -> Join p a -> Builder+showbJoinPrecWith sp p = showbPrecWith2 sp sp p . runJoin+{-# INLINE showbJoinPrecWith #-}++-- | Convert a 'Joker' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbJokerPrec :: Show (g b) => Int -> Joker g a b -> Builder+showbJokerPrec = showbPrec+{-# INLINE showbJokerPrec #-}++-- | Convert a 'Joker' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbJokerPrecWith :: Show1 g => (Int -> b -> Builder) -> Int -> Joker g a b -> Builder+showbJokerPrecWith sp = showbPrecWith2 undefined sp+{-# INLINE showbJokerPrecWith #-}++-- | Convert a 'Product' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbProductPrec :: (Show (f a b), Show (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: 1/+showbProductPrecWith2 :: (Show2 f, Show2 g)+ => (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> Product f g a b -> Builder+showbProductPrecWith2 = showbPrecWith2+{-# INLINE showbProductPrecWith2 #-}++-- | Convert a 'Tannen' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbTannenPrec :: Show (f (p a b)) => Int -> Tannen f p a b -> Builder+showbTannenPrec = showbPrec+{-# INLINE showbTannenPrec #-}++-- | Convert a 'Tannen' value to a 'Builder' with the given show functions+-- and precedence.+--+-- /Since: 1/+showbTannenPrecWith2 :: (Show1 f, Show2 p)+ => (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> Tannen f p a b -> Builder+showbTannenPrecWith2 = showbPrecWith2+{-# INLINE showbTannenPrecWith2 #-}++-- | Convert a 'WrappedBifunctor' value to a 'Builder' with the given precedence.+--+-- /Since: 1/+showbWrappedBifunctorPrec :: Show (p a b) => Int -> WrappedBifunctor p a b -> Builder+showbWrappedBifunctorPrec = showbPrec+{-# INLINE showbWrappedBifunctorPrec #-}++-- | Convert a 'WrappedBifunctor' value to a 'Builder' with the given show functions+-- and precedence.+--+-- /Since: 1/+showbWrappedBifunctorPrecWith2 :: Show2 p+ => (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> WrappedBifunctor p a b -> Builder+showbWrappedBifunctorPrecWith2 = showbPrecWith2+{-# INLINE showbWrappedBifunctorPrecWith2 #-}++instance Show (p (f a) (g b)) => Show (Biff p f g a b) where+ showbPrec = $(mkShowbPrec ''Biff)+instance (Show2 p, Show1 f, Show1 g, Show a) => Show1 (Biff p f g a) where+ showbPrecWith = showbPrecWith2 showbPrec+$(deriveShow2 ''Biff)++instance Show (f a) => Show (Clown f a b) where+ showbPrec = $(mkShowbPrec ''Clown)+$(deriveShow1 ''Clown)+$(deriveShow2 ''Clown)++instance Show (p b a) => Show (Flip p a b) where+ showbPrec = $(mkShowbPrec ''Flip)+instance (Show2 p, Show a) => Show1 (Flip p a) where+ showbPrecWith = showbPrecWith2 showbPrec+$(deriveShow2 ''Flip)++instance Show (p a a) => Show (Join p a) where+ showbPrec = $(mkShowbPrec ''Join)+instance Show2 p => Show1 (Join p) where+ showbPrecWith = showbJoinPrecWith++instance Show (g b) => Show (Joker g a b) where+ showbPrec = $(mkShowbPrec ''Joker)+instance Show1 g => Show1 (Joker g a) where+ showbPrecWith = $(mkShowbPrecWith ''Joker)+$(deriveShow2 ''Joker)++instance (Show (f a b), Show (g a b)) => Show (Product f g a b) where+ showbPrec = $(mkShowbPrec ''Product)+instance (Show2 f, Show2 g, Show a) => Show1 (Product f g a) where+ showbPrecWith = showbPrecWith2 showbPrec+$(deriveShow2 ''Product)++instance Show (f (p a b)) => Show (Tannen f p a b) where+ showbPrec = $(mkShowbPrec ''Tannen)+instance (Show1 f, Show2 p, Show a) => Show1 (Tannen f p a) where+ showbPrecWith = showbPrecWith2 showbPrec+$(deriveShow2 ''Tannen)++instance Show (p a b) => Show (WrappedBifunctor p a b) where+ showbPrec = $(mkShowbPrec ''WrappedBifunctor)+instance (Show2 p, Show a) => Show1 (WrappedBifunctor p a) where+ showbPrecWith = showbPrecWith2 showbPrec+$(deriveShow2 ''WrappedBifunctor)
src/Text/Show/Text/Data/Binary.hs view
@@ -1,42 +1,44 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Binary -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'Decoder's. - -/Since: 0.2/ --} -module Text.Show.Text.Data.Binary (showbDecoder) where - -import Data.Binary.Get.Internal (Decoder(..)) -import Data.Monoid.Compat - -import Prelude () - -import Text.Show.Text (Show(showb, showbPrec), Show1(showbPrec1), Builder, fromString) - -#include "inline.h" - --- | Convert a 'Decoder' to a 'Builder'. --- --- /Since: 0.2/ -showbDecoder :: Show a => Decoder a -> Builder -showbDecoder (Fail _ msg) = "Fail: " <> fromString msg -showbDecoder (Partial _) = "Partial _" -showbDecoder (Done _ a) = "Done: " <> showb a -showbDecoder (BytesRead _ _) = "BytesRead" - -instance Show a => Show (Decoder a) where - showb = showbDecoder - INLINE_INST_FUN(showb) - -instance Show1 Decoder where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module: Text.Show.Text.Data.Binary+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for 'Decoder's.++/Since: 0.2/+-}+module Text.Show.Text.Data.Binary (showbDecoderWith) where++import Data.Binary.Get.Internal (Decoder(..))+import Data.Monoid.Compat++import Prelude hiding (Show)++import Text.Show.Text (Show(..), Show1(..), Builder,+ fromString, showbPrec1)++#include "inline.h"++-- | Convert a 'Decoder' to a 'Builder' with the given show function.+--+-- /Since: 1/+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"++instance Show a => Show (Decoder a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 Decoder where+ showbPrecWith sp _ = showbDecoderWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)
src/Text/Show/Text/Data/Containers.hs view
@@ -1,157 +1,194 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Containers -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @containers@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Containers ( - showbIntMapPrec - , showbIntSetPrec - , showbMapPrec - , showbSequencePrec - , showbViewLPrec - , showbViewRPrec - , showbSetPrec - , showbTreePrec - ) where - -import qualified Data.Foldable as F - -import qualified Data.IntMap as IM -import Data.IntMap (IntMap) -import qualified Data.IntSet as IS -import Data.IntSet (IntSet) -import qualified Data.Map as M -import Data.Map (Map) -import Data.Sequence (Seq, ViewL, ViewR) -import qualified Data.Set as Set -import Data.Set (Set) -import Data.Tree (Tree) - -import Prelude hiding (Show) - -import Text.Show.Text (Builder, Show(showbPrec), Show1(showbPrec1)) -import Text.Show.Text.Data.Integral () -import Text.Show.Text.Data.List () -import Text.Show.Text.Data.Tuple () -import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec) -import Text.Show.Text.Utils (showbUnaryList) - -#include "inline.h" - --- | Convert an 'IntMap' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbIntMapPrec :: Show v => Int -> IntMap v -> Builder -showbIntMapPrec p = showbUnaryList p . IM.toList -{-# INLINE showbIntMapPrec #-} - --- | Convert an 'IntSet' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbIntSetPrec :: Int -> IntSet -> Builder -showbIntSetPrec p = showbUnaryList p . IS.toList -{-# INLINE showbIntSetPrec #-} - --- | Convert a 'Map' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMapPrec :: (Show k, Show v) => Int -> Map k v -> Builder -showbMapPrec p = showbUnaryList p . M.toList -{-# INLINE showbMapPrec #-} - --- | Convert a 'Sequence' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbSequencePrec :: Show a => Int -> Seq a -> Builder -showbSequencePrec p = showbUnaryList p . F.toList -{-# INLINE showbSequencePrec #-} - --- | Convert a 'ViewL' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbViewLPrec :: Show a => Int -> ViewL a -> Builder -showbViewLPrec = showbPrec -{-# INLINE showbViewLPrec #-} - --- | Convert a 'ViewR' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbViewRPrec :: Show a => Int -> ViewR a -> Builder -showbViewRPrec = showbPrec -{-# INLINE showbViewRPrec #-} - --- | Convert a 'Set' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbSetPrec :: Show a => Int -> Set a -> Builder -showbSetPrec p = showbUnaryList p . Set.toList -{-# INLINE showbSetPrec #-} - --- | Convert a 'Tree' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTreePrec :: Show a => Int -> Tree a -> Builder -showbTreePrec = showbPrec -{-# INLINE showbTreePrec #-} - -instance Show v => Show (IntMap v) where - showbPrec = showbIntMapPrec - INLINE_INST_FUN(showbPrec) - -instance Show IntSet where - showbPrec = showbIntSetPrec - INLINE_INST_FUN(showbPrec) - -instance (Show k, Show v) => Show (Map k v) where - showbPrec = showbMapPrec - INLINE_INST_FUN(showbPrec) - -instance Show a => Show (Seq a) where - showbPrec = showbSequencePrec - INLINE_INST_FUN(showbPrec) - -instance Show a => Show (Set a) where - showbPrec = showbSetPrec - INLINE_INST_FUN(showbPrec) - -$(deriveShowPragmas defaultInlineShowbPrec ''ViewL) -$(deriveShowPragmas defaultInlineShowbPrec ''ViewR) -$(deriveShowPragmas defaultInlineShowbPrec ''Tree) - -instance Show1 IntMap where - showbPrec1 = showbIntMapPrec - INLINE_INST_FUN(showbPrec1) - -instance Show k => Show1 (Map k) where - showbPrec1 = showbMapPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Seq where - showbPrec1 = showbSequencePrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 ViewL where - showbPrec1 = showbViewLPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 ViewR where - showbPrec1 = showbViewRPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Set where - showbPrec1 = showbSetPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Tree where - showbPrec1 = showbTreePrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Containers+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @containers@ library.++/Since: 0.1/+-}+module Text.Show.Text.Data.Containers (+ showbIntMapPrecWith+ , showbIntSetPrec+ , showbMapPrecWith2+ , showbSequencePrec+ , showbSequencePrecWith+ , showbViewLPrec+ , showbViewLPrecWith+ , showbViewRPrec+ , showbViewRPrecWith+ , showbSetPrec+ , showbSetPrecWith+ , showbTreePrec+ , showbTreePrecWith+ ) where++import qualified Data.Foldable as F++import qualified Data.IntMap as IM+import Data.IntMap (IntMap)+import qualified Data.IntSet as IS+import Data.IntSet (IntSet)+import qualified Data.Map as M+import Data.Map (Map)+import Data.Sequence (Seq, ViewL, ViewR)+import qualified Data.Set as Set+import Data.Set (Set)+import Data.Tree (Tree)++import Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Show1(..), Show2(..),+ Builder, showbPrec1)+import Text.Show.Text.Data.Integral ()+import Text.Show.Text.Data.Tuple (showb2TupleWith2)+import Text.Show.Text.TH (deriveShow, deriveShow1)+import Text.Show.Text.Utils (showbUnaryList, showbUnaryListWith)++#include "inline.h"++-- | Convert an 'IntMap' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbIntMapPrecWith :: (v -> Builder) -> Int -> IntMap v -> Builder+showbIntMapPrecWith sp p = showbUnaryListWith (showb2TupleWith2 showb sp) p . IM.toList+{-# INLINE showbIntMapPrecWith #-}++-- | Convert an 'IntSet' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbIntSetPrec :: Int -> IntSet -> Builder+showbIntSetPrec p = showbUnaryListWith showb p . IS.toList+{-# INLINE showbIntSetPrec #-}++-- | Convert a 'Map' to a 'Builder' with the given show functions and precedence.+--+-- /Since: 1/+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: 0.1/+showbSequencePrec :: Show a => Int -> Seq a -> Builder+showbSequencePrec p = showbUnaryList p . F.toList+{-# INLINE showbSequencePrec #-}++-- | Convert a 'Sequence' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+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: 0.1/+showbViewLPrec :: Show a => Int -> ViewL a -> Builder+showbViewLPrec = showbPrec+{-# INLINE showbViewLPrec #-}++-- | Convert a 'ViewL' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+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: 0.1/+showbViewRPrec :: Show a => Int -> ViewR a -> Builder+showbViewRPrec = showbPrec+{-# INLINE showbViewRPrec #-}++-- | Convert a 'ViewR' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+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: 0.1/+showbSetPrec :: Show a => Int -> Set a -> Builder+showbSetPrec p = showbUnaryList p . Set.toList+{-# INLINE showbSetPrec #-}++-- | Convert a 'Set' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+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: 0.1/+showbTreePrec :: Show a => Int -> Tree a -> Builder+showbTreePrec = showbPrec+{-# INLINE showbTreePrec #-}++-- | Convert a 'Tree' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbTreePrecWith :: (a -> Builder) -> Int -> Tree a -> Builder+showbTreePrecWith sp = showbPrecWith $ const sp+{-# INLINE showbTreePrecWith #-}++instance Show v => Show (IntMap v) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 IntMap where+ showbPrecWith sp = showbIntMapPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++instance Show IntSet where+ showbPrec = showbIntSetPrec+ INLINE_INST_FUN(showbPrec)++instance (Show k, Show v) => Show (Map k v) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show k => Show1 (Map k) where+ showbPrecWith = showbPrecWith2 showbPrec+ INLINE_INST_FUN(showbPrecWith)++instance Show2 Map where+ showbPrecWith2 sp1 sp2 = showbMapPrecWith2 (sp1 0) (sp2 0)+ INLINE_INST_FUN(showbPrecWith2)++instance Show a => Show (Seq a) where+ showbPrec = showbSequencePrec+ INLINE_INST_FUN(showbPrec)++instance Show1 Seq where+ showbPrecWith sp = showbSequencePrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++$(deriveShow ''ViewL)+$(deriveShow1 ''ViewL)++$(deriveShow ''ViewR)+$(deriveShow1 ''ViewR)++instance Show a => Show (Set a) where+ showbPrec = showbSetPrec+ INLINE_INST_FUN(showbPrec)++instance Show1 Set where+ showbPrecWith sp = showbSetPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++$(deriveShow ''Tree)+$(deriveShow1 ''Tree)
src/Text/Show/Text/Data/Functor/Trans.hs view
@@ -1,120 +1,131 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Functor.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' 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. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Functor.Trans ( - showbComposePrec - , showbConstantPrec - , showbProductPrec - , showbReversePrec - , showbSumPrec - ) 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 Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder, - showbUnary, showbUnary1, showbBinary1) - -#include "inline.h" - --- kludge to get type with the same instances as g a -newtype Apply g a = Apply (g a) - -instance (Show1 g, Show a) => Show (Apply g a) where - showbPrec p (Apply x) = showbPrec1 p x - INLINE_INST_FUN(showbPrec) - --- | Convert a 'Compose' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbComposePrec :: (Functor f, Show1 f, Show1 g, Show a) => Int -> Compose f g a -> Builder -showbComposePrec p (Compose x) = showbUnary1 "Compose" p $ fmap Apply x -{-# INLINE showbComposePrec #-} - --- | Convert a 'Constant' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbConstantPrec :: Show a => Int -> Constant a b -> Builder -showbConstantPrec p (Constant x) = showbUnary "Constant" p x -{-# INLINE showbConstantPrec #-} - --- | Convert a 'Product' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbProductPrec :: (Show1 f, Show1 g, Show a) => Int -> Product f g a -> Builder -showbProductPrec p (Pair x y) = showbBinary1 "Pair" p x y -{-# INLINE showbProductPrec #-} - --- | Convert a 'Reverse' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbReversePrec :: (Show1 f, Show a) => Int -> Reverse f a -> Builder -showbReversePrec p (Reverse x) = showbUnary1 "Reverse" p x -{-# INLINE showbReversePrec #-} - --- | Convert a 'Sum' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbSumPrec :: (Show1 f, Show1 g, Show a) => Int -> Sum f g a -> Builder -showbSumPrec p (InL x) = showbUnary1 "InL" p x -showbSumPrec p (InR y) = showbUnary1 "InR" p y -{-# INLINE showbSumPrec #-} - -instance (Functor f, Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showbPrec = showbComposePrec - INLINE_INST_FUN(showbPrec) - -instance (Functor f, Show1 f, Show1 g) => Show1 (Compose f g) where - showbPrec1 = showbComposePrec - INLINE_INST_FUN(showbPrec1) - -instance Show a => Show (Constant a b) where - showbPrec = showbConstantPrec - INLINE_INST_FUN(showbPrec) - -instance Show a => Show1 (Constant a) where - showbPrec1 = showbConstantPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showbPrec = showbProductPrec - INLINE_INST_FUN(showbPrec) - -instance (Show1 f, Show1 g) => Show1 (Product f g) where - showbPrec1 = showbProductPrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 f, Show a) => Show (Reverse f a) where - showbPrec = showbReversePrec - INLINE_INST_FUN(showbPrec) - -instance Show1 f => Show1 (Reverse f) where - showbPrec1 = showbReversePrec - INLINE_INST_FUN(showbPrec1) - -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showbPrec = showbSumPrec - INLINE_INST_FUN(showbPrec) - -instance (Show1 f, Show1 g) => Show1 (Sum f g) where - showbPrec1 = showbSumPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Functor.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' 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.++/Since: 0.1/+-}+module Text.Show.Text.Data.Functor.Trans (+ showbComposePrecWith+ , showbConstantPrecWith+ , showbProductPrecWith+ , showbReversePrecWith+ , showbSumPrecWith+ ) 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 Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Show1(..), Show2(..), Builder,+ showbPrec1, showbUnaryWith, showbBinaryWith)++#include "inline.h"++-- | Convert a 'Compose' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbComposePrecWith :: (Show1 f, Show1 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: 1/+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: 1/+showbProductPrecWith :: (Show1 f, Show1 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 #-}++-- | Convert a 'Reverse' value to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbReversePrecWith :: Show1 f+ => (Int -> 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: 1/+showbSumPrecWith :: (Show1 f, Show1 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 (Show1 f, Show1 g, Show a) => Show (Compose f g a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show1 f, Show1 g) => Show1 (Compose f g) where+ showbPrecWith = showbComposePrecWith+ INLINE_INST_FUN(showbPrecWith)++instance Show a => Show (Constant a b) where+ showbPrec = showbPrecWith undefined+ INLINE_INST_FUN(showbPrec)++instance Show a => Show1 (Constant a) where+ showbPrecWith = showbPrecWith2 showbPrec+ INLINE_INST_FUN(showbPrecWith)++instance Show2 Constant where+ showbPrecWith2 sp _ = showbConstantPrecWith sp+ INLINE_INST_FUN(showbPrecWith2)++instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show1 f, Show1 g) => Show1 (Product f g) where+ showbPrecWith = showbProductPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 f, Show a) => Show (Reverse f a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 f => Show1 (Reverse f) where+ showbPrecWith = showbReversePrecWith+ INLINE_INST_FUN(showbPrecWith)++instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance (Show1 f, Show1 g) => Show1 (Sum f g) where+ showbPrecWith = showbSumPrecWith+ INLINE_INST_FUN(showbPrecWith)
src/Text/Show/Text/Data/List/NonEmpty.hs view
@@ -1,38 +1,31 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.List.NonEmpty -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'NonEmpty' lists. - -/Since: 0.1/ --} -module Text.Show.Text.Data.List.NonEmpty (showbNonEmptyPrec) where - -import Data.List.NonEmpty (NonEmpty) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder) -import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec) - -#include "inline.h" - --- | Convert a 'NonEmpty' list to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbNonEmptyPrec :: Show a => Int -> NonEmpty a -> Builder -showbNonEmptyPrec = showbPrec -{-# INLINE showbNonEmptyPrec #-} - -$(deriveShowPragmas defaultInlineShowbPrec ''NonEmpty) - -instance Show1 NonEmpty where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.List.NonEmpty+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for 'NonEmpty' lists.++/Since: 0.1/+-}+module Text.Show.Text.Data.List.NonEmpty (showbNonEmptyPrecWith) where++import Data.List.NonEmpty (NonEmpty)++import Text.Show.Text (Show1(..), Builder)+import Text.Show.Text.TH (deriveShow, deriveShow1)++-- | Convert a 'NonEmpty' list to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbNonEmptyPrecWith :: (Int -> a -> Builder) -> Int -> NonEmpty a -> Builder+showbNonEmptyPrecWith = showbPrecWith+{-# INLINE showbNonEmptyPrecWith #-}++$(deriveShow ''NonEmpty)+$(deriveShow1 ''NonEmpty)
src/Text/Show/Text/Data/Semigroup.hs view
@@ -1,118 +1,107 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Semigroup -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for @Semigroup@ data types. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Semigroup ( - showbMinPrec - , showbMaxPrec - , showbFirstPrec - , showbLastPrec - , showbWrappedMonoidPrec - , showbOptionPrec - , showbArgPrec - ) where - -import Data.Semigroup (Min, Max, First, Last, WrappedMonoid, Option, Arg) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder) -import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec) - -#include "inline.h" - --- | Convert a 'Min' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMinPrec :: Show a => Int -> Min a -> Builder -showbMinPrec = showbPrec -{-# INLINE showbMinPrec #-} - --- | Convert a 'Max' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMaxPrec :: Show a => Int -> Max a -> Builder -showbMaxPrec = showbPrec -{-# INLINE showbMaxPrec #-} - --- | Convert a 'First' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbFirstPrec :: Show a => Int -> First a -> Builder -showbFirstPrec = showbPrec -{-# INLINE showbFirstPrec #-} - --- | Convert a 'Last' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbLastPrec :: Show a => Int -> Last a -> Builder -showbLastPrec = showbPrec -{-# INLINE showbLastPrec #-} - --- | Convert a 'WrappedMonoid' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbWrappedMonoidPrec :: Show m => Int -> WrappedMonoid m -> Builder -showbWrappedMonoidPrec = showbPrec -{-# INLINE showbWrappedMonoidPrec #-} - --- | Convert an 'Option' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbOptionPrec :: Show a => Int -> Option a -> Builder -showbOptionPrec = showbPrec -{-# INLINE showbOptionPrec #-} - --- | Convert an 'Arg' value to a 'Builder' with the given precedence. --- --- /Since: 0.3/ -showbArgPrec :: (Show a, Show b) => Int -> Arg a b -> Builder -showbArgPrec = showbPrec -{-# INLINE showbArgPrec #-} - -$(deriveShowPragmas defaultInlineShowbPrec ''Min) -$(deriveShowPragmas defaultInlineShowbPrec ''Max) -$(deriveShowPragmas defaultInlineShowbPrec ''First) -$(deriveShowPragmas defaultInlineShowbPrec ''Last) -$(deriveShowPragmas defaultInlineShowbPrec ''WrappedMonoid) -$(deriveShowPragmas defaultInlineShowbPrec ''Option) -$(deriveShowPragmas defaultInlineShowbPrec ''Arg) - -instance Show1 Min where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Max where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 First where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Last where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 WrappedMonoid where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 Option where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) - -instance Show a => Show1 (Arg a) where - showbPrec1 = showbPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Semigroup+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for @Semigroup@ data types.++/Since: 0.1/+-}+module Text.Show.Text.Data.Semigroup (+ showbMinPrecWith+ , showbMaxPrecWith+ , showbFirstPrecWith+ , showbLastPrecWith+ , showbWrappedMonoidPrecWith+ , showbOptionPrecWith+ , showbArgPrecWith2+ ) where++import Data.Semigroup (Min, Max, First, Last, WrappedMonoid, Option, Arg)++import Prelude hiding (Show)++import Text.Show.Text (Builder, showbPrecWith, showbPrecWith2)+import Text.Show.Text.TH (deriveShow, deriveShow1, deriveShow2)++#include "inline.h"++-- | Convert a 'Min' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+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: 1/+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: 1/+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: 1/+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: 1/+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: 1/+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: 1/+showbArgPrecWith2 :: (Int -> a -> Builder) -> (Int -> b -> Builder)+ -> Int -> Arg a b -> Builder+showbArgPrecWith2 = showbPrecWith2+{-# INLINE showbArgPrecWith2 #-}++$(deriveShow ''Min)+$(deriveShow1 ''Min)++$(deriveShow ''Max)+$(deriveShow1 ''Max)++$(deriveShow ''First)+$(deriveShow1 ''First)++$(deriveShow ''Last)+$(deriveShow1 ''Last)++$(deriveShow ''WrappedMonoid)+$(deriveShow1 ''WrappedMonoid)++$(deriveShow ''Option)+$(deriveShow1 ''Option)++$(deriveShow ''Arg)+$(deriveShow1 ''Arg)+$(deriveShow2 ''Arg)
− src/Text/Show/Text/Data/String/UTF8.hs
@@ -1,62 +0,0 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE UndecidableInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.String.UTF8 -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'UTF8' strings. - -/Since: 0.2/ --} -module Text.Show.Text.Data.String.UTF8 (showbUTF8, toBuilder, toBuilderGeneric) where - -import qualified Codec.Binary.UTF8.Generic as G (foldr) -import Codec.Binary.UTF8.Generic (UTF8Bytes) - -import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as BL -import Data.Monoid.Compat -import Data.String.UTF8 (UTF8, toRep) -import Data.Word (Word8) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showb), Builder) -import Text.Show.Text.Data.Text (showbBuilder) -import Text.Show.Text.Utils (s) - -#include "inline.h" - --- | Convert a 'UTF8' string to a 'Builder'. --- --- /Since: 0.2/ -showbUTF8 :: UTF8Bytes string index => UTF8 string -> Builder -showbUTF8 = showbBuilder . toBuilder -{-# INLINE showbUTF8 #-} - --- | Convert a 'UTF8'-encoded string to a 'Builder'. --- Invalid characters are replaced with '\xFFFD'. --- --- /Since: 0.2/ -toBuilder :: UTF8Bytes string index => UTF8 string -> Builder -toBuilder = toBuilderGeneric . toRep -{-# INLINE toBuilder #-} - --- | Convert a 'UTF8'-encoded bytestring to a 'Builder'. --- Invalid characters are replaced with '\xFFFD'. --- --- /Since: 0.2/ -toBuilderGeneric :: UTF8Bytes bytestring index => bytestring -> Builder -toBuilderGeneric = G.foldr ((<>) . s) mempty -{-# SPECIALIZE toBuilderGeneric :: BS.ByteString -> Builder #-} -{-# SPECIALIZE toBuilderGeneric :: BL.ByteString -> Builder #-} -{-# SPECIALIZE toBuilderGeneric :: [Word8] -> Builder #-} - -instance UTF8Bytes string index => Show (UTF8 string) where - showb = showbUTF8 - INLINE_INST_FUN(showb)
src/Text/Show/Text/Data/Tagged.hs view
@@ -1,38 +1,42 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Tagged -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'Tagged' values. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Tagged (showbTaggedPrec) where - -import Data.Tagged (Tagged(..)) -import Prelude hiding (Show) -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), - Builder, showbUnary) - -#include "inline.h" - --- | Convert a 'Tagged' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTaggedPrec :: Show b => Int -> Tagged s b -> Builder -showbTaggedPrec p (Tagged b) = showbUnary "Tagged" p b -{-# INLINE showbTaggedPrec #-} - -instance Show b => Show (Tagged s b) where - showbPrec = showbTaggedPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 (Tagged s) where - showbPrec1 = showbTaggedPrec - INLINE_INST_FUN(showbPrec1) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Tagged+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for 'Tagged' values.++/Since: 0.1/+-}+module Text.Show.Text.Data.Tagged (showbTaggedPrecWith) where++import Data.Tagged (Tagged(..))+import Prelude hiding (Show)+import Text.Show.Text (Show(showbPrec), Show1(..), Show2(..), Builder,+ showbPrec1, showbUnaryWith)++#include "inline.h"++-- | Convert a 'Tagged' value to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbTaggedPrecWith :: (Int -> b -> Builder) -> Int -> Tagged s b -> Builder+showbTaggedPrecWith sp p (Tagged b) = showbUnaryWith sp "Tagged" p b+{-# INLINE showbTaggedPrecWith #-}++instance Show b => Show (Tagged s b) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show1 (Tagged s) where+ showbPrecWith = showbTaggedPrecWith+ INLINE_INST_FUN(showbPrecWith)++instance Show2 Tagged where+ showbPrecWith2 _ = showbTaggedPrecWith+ INLINE_INST_FUN(showbPrecWith2)
src/Text/Show/Text/Data/Time.hs view
@@ -1,234 +1,233 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -#if MIN_VERSION_time(1,5,0) -{-# LANGUAGE TemplateHaskell #-} -#endif -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Time -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @time@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Time ( - showbDay - , showbDiffTime - , showbUTCTime - , showbNominalDiffTime - , showbAbsoluteTime - , showbTimeZone - , showbTimeOfDay - , showbLocalTime - , showbZonedTime -#if MIN_VERSION_time(1,5,0) - , showbTimeLocalePrec -#endif - ) where - -import Data.Fixed (Pico) -import Data.Monoid.Compat -import Data.Semigroup (timesN) -import Data.Time.Calendar (Day, toGregorian) -import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime) -import Data.Time.Clock.TAI (AbsoluteTime, taiToUTCTime) -import Data.Time.Format (NumericPadOption) -import Data.Time.LocalTime (TimeZone(..), TimeOfDay(..), LocalTime(..), ZonedTime(..), - utc, utcToLocalTime, utcToZonedTime) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showb), Builder, FromStringShow(..), - fromString, lengthB, showbSpace) -import Text.Show.Text.Data.Fixed (showbFixed) -import Text.Show.Text.Data.Integral () -import Text.Show.Text.Utils (s) - -#if MIN_VERSION_time(1,5,0) -import Data.Time.Format (TimeLocale) - -import Text.Show.Text (showbPrec) -import Text.Show.Text.TH (deriveShow) -#endif - -#include "inline.h" - --- | Convert a 'Day' into a 'Builder'. --- --- /Since: 0.1/ -showbDay :: Day -> Builder -showbDay = showbGregorian -{-# INLINE showbDay #-} - --- | Convert a 'DiffTime' into a 'Builder'. --- --- /Since: 0.1/ -showbDiffTime :: DiffTime -> Builder -showbDiffTime = showb . FromStringShow -{-# INLINE showbDiffTime #-} - --- | Convert a 'UTCTime' into a 'Builder'. --- --- /Since: 0.1/ -showbUTCTime :: UTCTime -> Builder -showbUTCTime = showb . utcToZonedTime utc -{-# INLINE showbUTCTime #-} - --- | Convert a 'NominalDiffTime' into a 'Builder'. --- --- /Since: 0.1/ -showbNominalDiffTime :: NominalDiffTime -> Builder -showbNominalDiffTime = showb . FromStringShow -{-# INLINE showbNominalDiffTime #-} - --- | Convert a 'AbsoluteTime' into a 'Builder'. --- --- /Since: 0.1/ -showbAbsoluteTime :: AbsoluteTime -> Builder -showbAbsoluteTime t = showbLocalTime (utcToLocalTime utc $ taiToUTCTime (const 0) t) - <> " TAI" -- ugly, but standard apparently -{-# INLINE showbAbsoluteTime #-} - --- | Convert a 'TimeZone' into a 'Builder'. --- --- /Since: 0.1/ -showbTimeZone :: TimeZone -> Builder -showbTimeZone zone@(TimeZone _ _ "") = timeZoneOffsetBuilder zone -showbTimeZone (TimeZone _ _ name) = fromString name -{-# INLINE showbTimeZone #-} - --- | Convert a 'TimeOfDay' into a 'Builder'. --- --- /Since: 0.1/ -showbTimeOfDay :: TimeOfDay -> Builder -showbTimeOfDay (TimeOfDay h m sec) = showb2 zeroOpt h - <> s ':' - <> showb2 zeroOpt m - <> s ':' - <> showb2Fixed zeroOpt sec -{-# INLINE showbTimeOfDay #-} - --- | Convert a 'LocalTime' into a 'Builder'. --- --- /Since: 0.1/ -showbLocalTime :: LocalTime -> Builder -showbLocalTime (LocalTime d t) = showbGregorian d <> showbSpace <> showb t -{-# INLINE showbLocalTime #-} - --- | Convert a 'ZonedTime' into a 'Builder'. --- --- /Since: 0.1/ -showbZonedTime :: ZonedTime -> Builder -showbZonedTime (ZonedTime t zone) = showb t <> showbSpace <> showb zone -{-# INLINE showbZonedTime #-} - -pad1 :: NumericPadOption -> Builder -> Builder -pad1 (Just c) b = s c <> b -pad1 _ b = b -{-# INLINE pad1 #-} - -padN :: Int -> Char -> Builder -> Builder -padN i _ b | i <= 0 = b -padN i c b = timesN (fromIntegral i) (s c) <> b -{-# INLINE padN #-} - -showb2 :: (Num t, Ord t, Show t) => NumericPadOption -> t -> Builder -showb2 = showbPaddedMin 2 -{-# INLINE showb2 #-} - -showb2Fixed :: NumericPadOption -> Pico -> Builder -showb2Fixed opt x | x < 10 = pad1 opt $ showbFixed True x -showb2Fixed _ x = showbFixed True x -{-# INLINE showb2Fixed #-} - -showb4 :: (Num t, Ord t, Show t) => NumericPadOption -> t -> Builder -showb4 = showbPaddedMin 4 -{-# INLINE showb4 #-} - -showbGregorian :: Day -> Builder -showbGregorian date = showb4 zeroOpt y - <> s '-' - <> showb2 zeroOpt m - <> s '-' - <> showb2 zeroOpt d - where - (y,m,d) = toGregorian date - -showbPaddedMin :: (Num t, Ord t, Show t) => Int -> NumericPadOption -> t -> Builder -showbPaddedMin _ Nothing i = showb i -showbPaddedMin pl opt i | i < 0 = s '-' <> showbPaddedMin pl opt (negate i) -showbPaddedMin pl (Just c) i = - let b = showb i - in padN (pl - fromIntegral (lengthB b)) c b - -showbT :: NumericPadOption -> Int -> Builder -showbT opt t = showb4 opt ((div t 60) * 100 + (mod t 60)) -{-# INLINE showbT #-} - -timeZoneOffsetBuilder' :: NumericPadOption -> TimeZone -> Builder -timeZoneOffsetBuilder' opt (TimeZone t _ _) | t < 0 = s '-' <> showbT opt (negate t) -timeZoneOffsetBuilder' opt (TimeZone t _ _) = s '+' <> showbT opt t -{-# INLINE timeZoneOffsetBuilder' #-} - -timeZoneOffsetBuilder :: TimeZone -> Builder -timeZoneOffsetBuilder = timeZoneOffsetBuilder' $ Just '0' -{-# INLINE timeZoneOffsetBuilder #-} - -zeroOpt :: NumericPadOption -zeroOpt = Just '0' -{-# INLINE zeroOpt #-} - -#if MIN_VERSION_time(1,5,0) --- | Convert a 'TimeLocale' to a 'Builder' with the given precedence. This function is --- available with @time-1.5@ or later. --- --- /Since: 0.2/ -showbTimeLocalePrec :: Int -> TimeLocale -> Builder -showbTimeLocalePrec = showbPrec -{-# INLINE showbTimeLocalePrec #-} -#endif - -instance Show Day where - showb = showbDay - INLINE_INST_FUN(showb) - -instance Show DiffTime where - showb = showbDiffTime - INLINE_INST_FUN(showb) - -instance Show UTCTime where - showb = showbUTCTime - INLINE_INST_FUN(showb) - -instance Show NominalDiffTime where - showb = showbNominalDiffTime - INLINE_INST_FUN(showb) - -instance Show AbsoluteTime where - showb = showbAbsoluteTime - INLINE_INST_FUN(showb) - -instance Show TimeZone where - showb = showbTimeZone - INLINE_INST_FUN(showb) - -instance Show TimeOfDay where - showb = showbTimeOfDay - INLINE_INST_FUN(showb) - -instance Show LocalTime where - showb = showbLocalTime - INLINE_INST_FUN(showb) - -instance Show ZonedTime where - showb = showbZonedTime - INLINE_INST_FUN(showb) - -#if MIN_VERSION_time(1,5,0) -$(deriveShow ''TimeLocale) -#endif +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+#if MIN_VERSION_time(1,5,0)+{-# LANGUAGE TemplateHaskell #-}+#endif+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Time+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @time@ library.++/Since: 0.1/+-}+module Text.Show.Text.Data.Time (+ showbDay+ , showbDiffTime+ , showbUTCTime+ , showbNominalDiffTime+ , showbAbsoluteTime+ , showbTimeZone+ , showbTimeOfDay+ , showbLocalTime+ , showbZonedTime+#if MIN_VERSION_time(1,5,0)+ , showbTimeLocalePrec+#endif+ ) where++import Data.Fixed (Pico)+import Data.Monoid.Compat+import Data.Semigroup (timesN)+import Data.Time.Calendar (Day, toGregorian)+import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime)+import Data.Time.Clock.TAI (AbsoluteTime, taiToUTCTime)+import Data.Time.Format (NumericPadOption)+import Data.Time.LocalTime (TimeZone(..), TimeOfDay(..), LocalTime(..), ZonedTime(..),+ utc, utcToLocalTime, utcToZonedTime)++import Prelude hiding (Show)++import Text.Show.Text (Show(showb), Builder, FromStringShow(..),+ fromString, lengthB, showbSpace, singleton)+import Text.Show.Text.Data.Fixed (showbFixed)+import Text.Show.Text.Data.Integral ()++#if MIN_VERSION_time(1,5,0)+import Data.Time.Format (TimeLocale)++import Text.Show.Text (showbPrec)+import Text.Show.Text.TH (deriveShow)+#endif++#include "inline.h"++-- | Convert a 'Day' into a 'Builder'.+--+-- /Since: 0.1/+showbDay :: Day -> Builder+showbDay = showbGregorian+{-# INLINE showbDay #-}++-- | Convert a 'DiffTime' into a 'Builder'.+--+-- /Since: 0.1/+showbDiffTime :: DiffTime -> Builder+showbDiffTime = showb . FromStringShow+{-# INLINE showbDiffTime #-}++-- | Convert a 'UTCTime' into a 'Builder'.+--+-- /Since: 0.1/+showbUTCTime :: UTCTime -> Builder+showbUTCTime = showb . utcToZonedTime utc+{-# INLINE showbUTCTime #-}++-- | Convert a 'NominalDiffTime' into a 'Builder'.+--+-- /Since: 0.1/+showbNominalDiffTime :: NominalDiffTime -> Builder+showbNominalDiffTime = showb . FromStringShow+{-# INLINE showbNominalDiffTime #-}++-- | Convert a 'AbsoluteTime' into a 'Builder'.+--+-- /Since: 0.1/+showbAbsoluteTime :: AbsoluteTime -> Builder+showbAbsoluteTime t = showbLocalTime (utcToLocalTime utc $ taiToUTCTime (const 0) t)+ <> " TAI" -- ugly, but standard apparently+{-# INLINE showbAbsoluteTime #-}++-- | Convert a 'TimeZone' into a 'Builder'.+--+-- /Since: 0.1/+showbTimeZone :: TimeZone -> Builder+showbTimeZone zone@(TimeZone _ _ "") = timeZoneOffsetBuilder zone+showbTimeZone (TimeZone _ _ name) = fromString name+{-# INLINE showbTimeZone #-}++-- | Convert a 'TimeOfDay' into a 'Builder'.+--+-- /Since: 0.1/+showbTimeOfDay :: TimeOfDay -> Builder+showbTimeOfDay (TimeOfDay h m sec) = showb2 zeroOpt h+ <> singleton ':'+ <> showb2 zeroOpt m+ <> singleton ':'+ <> showb2Fixed zeroOpt sec+{-# INLINE showbTimeOfDay #-}++-- | Convert a 'LocalTime' into a 'Builder'.+--+-- /Since: 0.1/+showbLocalTime :: LocalTime -> Builder+showbLocalTime (LocalTime d t) = showbGregorian d <> showbSpace <> showb t+{-# INLINE showbLocalTime #-}++-- | Convert a 'ZonedTime' into a 'Builder'.+--+-- /Since: 0.1/+showbZonedTime :: ZonedTime -> Builder+showbZonedTime (ZonedTime t zone) = showb t <> showbSpace <> showb zone+{-# INLINE showbZonedTime #-}++pad1 :: NumericPadOption -> Builder -> Builder+pad1 (Just c) b = singleton c <> b+pad1 _ b = b+{-# INLINE pad1 #-}++padN :: Int -> Char -> Builder -> Builder+padN i _ b | i <= 0 = b+padN i c b = timesN (fromIntegral i) (singleton c) <> b+{-# INLINE padN #-}++showb2 :: (Num t, Ord t, Show t) => NumericPadOption -> t -> Builder+showb2 = showbPaddedMin 2+{-# INLINE showb2 #-}++showb2Fixed :: NumericPadOption -> Pico -> Builder+showb2Fixed opt x | x < 10 = pad1 opt $ showbFixed True x+showb2Fixed _ x = showbFixed True x+{-# INLINE showb2Fixed #-}++showb4 :: (Num t, Ord t, Show t) => NumericPadOption -> t -> Builder+showb4 = showbPaddedMin 4+{-# INLINE showb4 #-}++showbGregorian :: Day -> Builder+showbGregorian date = showb4 zeroOpt y+ <> singleton '-'+ <> showb2 zeroOpt m+ <> singleton '-'+ <> showb2 zeroOpt d+ where+ (y,m,d) = toGregorian date++showbPaddedMin :: (Num t, Ord t, Show t) => Int -> NumericPadOption -> t -> Builder+showbPaddedMin _ Nothing i = showb i+showbPaddedMin pl opt i | i < 0 = singleton '-' <> showbPaddedMin pl opt (negate i)+showbPaddedMin pl (Just c) i =+ let b = showb i+ in padN (pl - fromIntegral (lengthB b)) c b++showbT :: NumericPadOption -> Int -> Builder+showbT opt t = showb4 opt ((div t 60) * 100 + (mod t 60))+{-# INLINE showbT #-}++timeZoneOffsetBuilder' :: NumericPadOption -> TimeZone -> Builder+timeZoneOffsetBuilder' opt (TimeZone t _ _) | t < 0 = singleton '-' <> showbT opt (negate t)+timeZoneOffsetBuilder' opt (TimeZone t _ _) = singleton '+' <> showbT opt t+{-# INLINE timeZoneOffsetBuilder' #-}++timeZoneOffsetBuilder :: TimeZone -> Builder+timeZoneOffsetBuilder = timeZoneOffsetBuilder' $ Just '0'+{-# INLINE timeZoneOffsetBuilder #-}++zeroOpt :: NumericPadOption+zeroOpt = Just '0'+{-# INLINE zeroOpt #-}++#if MIN_VERSION_time(1,5,0)+-- | Convert a 'TimeLocale' to a 'Builder' with the given precedence. This function is+-- available with @time-1.5@ or later.+--+-- /Since: 0.2/+showbTimeLocalePrec :: Int -> TimeLocale -> Builder+showbTimeLocalePrec = showbPrec+{-# INLINE showbTimeLocalePrec #-}+#endif++instance Show Day where+ showb = showbDay+ INLINE_INST_FUN(showb)++instance Show DiffTime where+ showb = showbDiffTime+ INLINE_INST_FUN(showb)++instance Show UTCTime where+ showb = showbUTCTime+ INLINE_INST_FUN(showb)++instance Show NominalDiffTime where+ showb = showbNominalDiffTime+ INLINE_INST_FUN(showb)++instance Show AbsoluteTime where+ showb = showbAbsoluteTime+ INLINE_INST_FUN(showb)++instance Show TimeZone where+ showb = showbTimeZone+ INLINE_INST_FUN(showb)++instance Show TimeOfDay where+ showb = showbTimeOfDay+ INLINE_INST_FUN(showb)++instance Show LocalTime where+ showb = showbLocalTime+ INLINE_INST_FUN(showb)++instance Show ZonedTime where+ showb = showbZonedTime+ INLINE_INST_FUN(showb)++#if MIN_VERSION_time(1,5,0)+$(deriveShow ''TimeLocale)+#endif
src/Text/Show/Text/Data/UnorderedContainers.hs view
@@ -1,57 +1,76 @@-{-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.UnorderedContainers -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for 'HashMap's and 'HashSet's. - -/Since: 0.1/ --} -module Text.Show.Text.Data.UnorderedContainers (showbHashMapPrec, showbHashSetPrec) where - -import qualified Data.HashMap.Lazy as HM (toList) -import Data.HashMap.Lazy (HashMap) -import qualified Data.HashSet as HS (toList) -import Data.HashSet (HashSet) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder) -import Text.Show.Text.Utils (showbUnaryList) - -#include "inline.h" - --- | Convert a 'HashMap' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbHashMapPrec :: (Show k, Show v) => Int -> HashMap k v -> Builder -showbHashMapPrec p = showbUnaryList p . HM.toList -{-# INLINE showbHashMapPrec #-} - --- | Convert a 'HashSet' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbHashSetPrec :: Show a => Int -> HashSet a -> Builder -showbHashSetPrec p = showbUnaryList p . HS.toList -{-# INLINE showbHashSetPrec #-} - -instance (Show k, Show v) => Show (HashMap k v) where - showbPrec = showbHashMapPrec - INLINE_INST_FUN(showbPrec) - -instance Show a => Show (HashSet a) where - showbPrec = showbHashSetPrec - INLINE_INST_FUN(showbPrec) - -instance Show k => Show1 (HashMap k) where - showbPrec1 = showbHashMapPrec - INLINE_INST_FUN(showbPrec1) - -instance Show1 HashSet where - showbPrec1 = showbHashSetPrec - INLINE_INST_FUN(showbPrec1)+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.UnorderedContainers+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for 'HashMap's and 'HashSet's.++/Since: 0.1/+-}+module Text.Show.Text.Data.UnorderedContainers (+ showbHashMapPrecWith2+ , showbHashSetPrec+ , showbHashSetPrecWith+ ) where++import qualified Data.HashMap.Lazy as HM (toList)+import Data.HashMap.Lazy (HashMap)+import qualified Data.HashSet as HS (toList)+import Data.HashSet (HashSet)++import Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Show1(..), Show2(..),+ Builder, showbPrec1)+import Text.Show.Text.Data.Tuple (showb2TupleWith2)+import Text.Show.Text.Utils (showbUnaryList, showbUnaryListWith)++#include "inline.h"++-- | Convert a 'HashMap' to a 'Builder' with the given show functions and precedence.+--+-- /Since: 1/+showbHashMapPrecWith2 :: (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: 0.1/+showbHashSetPrec :: Show a => Int -> HashSet a -> Builder+showbHashSetPrec p = showbUnaryList p . HS.toList+{-# INLINE showbHashSetPrec #-}++-- | Convert a 'HashSet' to a 'Builder' with the given show function and precedence.+--+-- /Since: 1/+showbHashSetPrecWith :: (a -> Builder) -> Int -> HashSet a -> Builder+showbHashSetPrecWith sp p = showbUnaryListWith sp p . HS.toList+{-# INLINE showbHashSetPrecWith #-}++instance (Show k, Show v) => Show (HashMap k v) where+ showbPrec = showbPrec1+ INLINE_INST_FUN(showbPrec)++instance Show k => Show1 (HashMap k) where+ showbPrecWith = showbPrecWith2 showbPrec+ INLINE_INST_FUN(showbPrecWith)++instance Show2 HashMap where+ showbPrecWith2 sp1 sp2 = showbHashMapPrecWith2 (sp1 0) (sp2 0)+ INLINE_INST_FUN(showbPrecWith2)++instance Show a => Show (HashSet a) where+ showbPrec = showbHashSetPrec+ INLINE_INST_FUN(showbPrec)++instance Show1 HashSet where+ showbPrecWith sp = showbHashSetPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)
src/Text/Show/Text/Data/Vector.hs view
@@ -1,107 +1,125 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Data.Vector -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for @Vector@ types. - -/Since: 0.1/ --} -module Text.Show.Text.Data.Vector ( - showbVectorPrec - , showbVectorGenericPrec - , showbVectorPrimitivePrec - , showbVectorStorablePrec - , showbVectorUnboxedPrec - , showbSizePrec - ) where - -import qualified Data.Vector as B (Vector) -import Data.Vector.Fusion.Stream.Size (Size) -import qualified Data.Vector.Generic as G (Vector) -import Data.Vector.Generic (toList) -import qualified Data.Vector.Primitive as P (Vector) -import Data.Vector.Primitive (Prim) -import qualified Data.Vector.Storable as S (Vector) -import qualified Data.Vector.Unboxed as U (Vector) -import Data.Vector.Unboxed (Unbox) - -import Foreign.Storable (Storable) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder) -import Text.Show.Text.TH (deriveShow) -import Text.Show.Text.Utils (showbUnaryList) - -#include "inline.h" - --- | Convert a boxed 'B.Vector' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbVectorPrec :: Show a => Int -> B.Vector a -> Builder -showbVectorPrec = showbVectorGenericPrec -{-# INLINE showbVectorPrec #-} - --- | Convert a generic 'G.Vector' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbVectorGenericPrec :: (G.Vector v a, Show a) => Int -> v a -> Builder -showbVectorGenericPrec p = showbUnaryList p . toList -{-# INLINE showbVectorGenericPrec #-} - --- | Convert a primitive 'P.Vector' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbVectorPrimitivePrec :: (Show a, Prim a) => Int -> P.Vector a -> Builder -showbVectorPrimitivePrec = showbVectorGenericPrec -{-# INLINE showbVectorPrimitivePrec #-} - --- | Convert a storable 'S.Vector' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbVectorStorablePrec :: (Show a, Storable a) => Int -> S.Vector a -> Builder -showbVectorStorablePrec = showbVectorGenericPrec -{-# INLINE showbVectorStorablePrec #-} - --- | Convert an unboxed 'U.Vector' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbVectorUnboxedPrec :: (Show a, Unbox a) => Int -> U.Vector a -> Builder -showbVectorUnboxedPrec = showbVectorGenericPrec -{-# INLINE showbVectorUnboxedPrec #-} - --- | Convert a 'Size' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbSizePrec :: Int -> Size -> Builder -showbSizePrec = showbPrec -{-# INLINE showbSizePrec #-} - -instance Show a => Show (B.Vector a) where - showbPrec = showbVectorPrec - INLINE_INST_FUN(showbPrec) - -instance (Show a, Prim a) => Show (P.Vector a) where - showbPrec = showbVectorPrimitivePrec - INLINE_INST_FUN(showbPrec) - -instance (Show a, Storable a) => Show (S.Vector a) where - showbPrec = showbVectorStorablePrec - INLINE_INST_FUN(showbPrec) - -instance (Show a, Unbox a) => Show (U.Vector a) where - showbPrec = showbVectorUnboxedPrec - INLINE_INST_FUN(showbPrec) - -instance Show1 B.Vector where - showbPrec1 = showbVectorPrec - INLINE_INST_FUN(showbPrec1) - -$(deriveShow ''Size) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Data.Vector+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for @Vector@ types.++/Since: 0.1/+-}+module Text.Show.Text.Data.Vector (+ showbVectorPrec+ , showbVectorPrecWith+ , showbVectorGenericPrec+ , showbVectorGenericPrecWith+ , showbVectorPrimitivePrec+ , showbVectorStorablePrec+ , showbVectorUnboxedPrec+ , showbSizePrec+ ) where++import qualified Data.Vector as B (Vector)+import Data.Vector.Fusion.Stream.Size (Size)+import qualified Data.Vector.Generic as G (Vector)+import Data.Vector.Generic (toList)+import qualified Data.Vector.Primitive as P (Vector)+import Data.Vector.Primitive (Prim)+import qualified Data.Vector.Storable as S (Vector)+import qualified Data.Vector.Unboxed as U (Vector)+import Data.Vector.Unboxed (Unbox)++import Foreign.Storable (Storable)++import Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Show1(..), Builder)+import Text.Show.Text.TH (deriveShow)+import Text.Show.Text.Utils (showbUnaryList, showbUnaryListWith)++#include "inline.h"++-- | Convert a boxed 'B.Vector' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbVectorPrec :: Show 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.+--+-- /Since: 1/+showbVectorPrecWith :: (a -> Builder) -> Int -> B.Vector a -> Builder+showbVectorPrecWith = showbVectorGenericPrecWith+{-# INLINE showbVectorPrecWith #-}++-- | Convert a generic 'G.Vector' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbVectorGenericPrec :: (G.Vector v a, Show a) => Int -> v a -> Builder+showbVectorGenericPrec p = showbUnaryList p . toList+{-# INLINE showbVectorGenericPrec #-}++-- | Convert a generic 'G.Vector' to a 'Builder' with the given show function+-- and precedence.+--+-- /Since: 1/+showbVectorGenericPrecWith :: G.Vector v a => (a -> Builder) -> Int -> v a -> Builder+showbVectorGenericPrecWith sp p = showbUnaryListWith sp p . toList+{-# INLINE showbVectorGenericPrecWith #-}++-- | Convert a primitive 'P.Vector' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbVectorPrimitivePrec :: (Show a, Prim a) => Int -> P.Vector a -> Builder+showbVectorPrimitivePrec = showbVectorGenericPrec+{-# INLINE showbVectorPrimitivePrec #-}++-- | Convert a storable 'S.Vector' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbVectorStorablePrec :: (Show a, Storable a) => Int -> S.Vector a -> Builder+showbVectorStorablePrec = showbVectorGenericPrec+{-# INLINE showbVectorStorablePrec #-}++-- | Convert an unboxed 'U.Vector' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbVectorUnboxedPrec :: (Show a, Unbox a) => Int -> U.Vector a -> Builder+showbVectorUnboxedPrec = showbVectorGenericPrec+{-# INLINE showbVectorUnboxedPrec #-}++-- | Convert a 'Size' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbSizePrec :: Int -> Size -> Builder+showbSizePrec = showbPrec+{-# INLINE showbSizePrec #-}++instance Show a => Show (B.Vector a) where+ showbPrec = showbVectorPrec+ INLINE_INST_FUN(showbPrec)++instance Show1 B.Vector where+ showbPrecWith sp = showbVectorPrecWith $ sp 0+ INLINE_INST_FUN(showbPrecWith)++instance (Show a, Prim a) => Show (P.Vector a) where+ showbPrec = showbVectorPrimitivePrec+ INLINE_INST_FUN(showbPrec)++instance (Show a, Storable a) => Show (S.Vector a) where+ showbPrec = showbVectorStorablePrec+ INLINE_INST_FUN(showbPrec)++instance (Show a, Unbox a) => Show (U.Vector a) where+ showbPrec = showbVectorUnboxedPrec+ INLINE_INST_FUN(showbPrec)++$(deriveShow ''Size)
src/Text/Show/Text/Instances.hs view
@@ -1,43 +1,43 @@-{-| -Module: Text.Show.Text.Instances -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Additional @Show@ instances not provided by @text-show@. - -/Since: 0.1/ --} -module Text.Show.Text.Instances () where - -import Text.Show.Text.Compiler.Hoopl () - -import Text.Show.Text.Control.Applicative.Trans () -import Text.Show.Text.Control.Monad.Trans () - -import Text.Show.Text.Data.Binary () -import Text.Show.Text.Data.Containers () -import Text.Show.Text.Data.Functor.Trans () -import Text.Show.Text.Data.List.NonEmpty () -import Text.Show.Text.Data.Semigroup () -import Text.Show.Text.Data.String.UTF8 () -import Text.Show.Text.Data.Tagged () -import Text.Show.Text.Data.Time () -import Text.Show.Text.Data.UnorderedContainers () -import Text.Show.Text.Data.Vector () - -import Text.Show.Text.Language.Haskell.TH () - -import Text.Show.Text.System.Console.Haskeline () -import Text.Show.Text.System.Console.Terminfo () -import Text.Show.Text.System.Locale () -import Text.Show.Text.System.Posix () -import Text.Show.Text.System.Random () -import Text.Show.Text.System.Time () -import Text.Show.Text.System.Win32 () - -import Text.Show.Text.Text.PrettyPrint () - -import Text.Show.Text.Trace.Hpc () +{-|+Module: Text.Show.Text.Instances+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Additional @Show@ instances not provided by @text-show@.++/Since: 0.1/+-}+module Text.Show.Text.Instances () where++import Text.Show.Text.Compiler.Hoopl ()++import Text.Show.Text.Control.Applicative.Trans ()+import Text.Show.Text.Control.Monad.Trans ()++import Text.Show.Text.Data.Bifunctor ()+import Text.Show.Text.Data.Binary ()+import Text.Show.Text.Data.Containers ()+import Text.Show.Text.Data.Functor.Trans ()+import Text.Show.Text.Data.List.NonEmpty ()+import Text.Show.Text.Data.Semigroup ()+import Text.Show.Text.Data.Tagged ()+import Text.Show.Text.Data.Time ()+import Text.Show.Text.Data.UnorderedContainers ()+import Text.Show.Text.Data.Vector ()++import Text.Show.Text.Language.Haskell.TH ()++import Text.Show.Text.System.Console.Haskeline ()+import Text.Show.Text.System.Console.Terminfo ()+import Text.Show.Text.System.Locale ()+import Text.Show.Text.System.Posix ()+import Text.Show.Text.System.Random ()+import Text.Show.Text.System.Time ()+import Text.Show.Text.System.Win32 ()++import Text.Show.Text.Text.PrettyPrint ()++import Text.Show.Text.Trace.Hpc ()
src/Text/Show/Text/Language/Haskell/TH.hs view
@@ -1,518 +1,517 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeSynonymInstances #-} -#if !(MIN_VERSION_template_haskell(2,10,0)) -{-# LANGUAGE MagicHash #-} -#endif -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Language.Haskell.TH -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @template-haskell@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Language.Haskell.TH ( -#if MIN_VERSION_template_haskell(2,9,0) - showbAnnLookupPrec - , showbAnnTargetPrec, -#endif - showbBodyPrec - , showbCallconv -#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0)) - , showbClassInstancePrec -#endif - , showbClausePrec - , showbConPrec - , showbDecPrec - , showbExpPrec - , showbFamFlavour - , showbFixityPrec - , showbFixityDirection - , showbForeignPrec - , showbFunDepPrec - , showbGuardPrec - , showbInfoPrec -#if MIN_VERSION_template_haskell(2,8,0) - , showbInline -#else - , showbInlineSpecPrec -#endif - , showbKindPrec - , showbLitPrec - , showbLocPrec - , showbMatchPrec - , showbModNamePrec -#if MIN_VERSION_template_haskell(2,9,0) - , showbModulePrec - , showbModuleInfoPrec -#endif - , showbName - , showbName' - , showbOccNamePrec - , showbPatPrec -#if MIN_VERSION_template_haskell(2,8,0) - , showbPhasesPrec -#endif - , showbPkgNamePrec - , showbPragmaPrec - , showbPredPrec - , showbRangePrec -#if MIN_VERSION_template_haskell(2,9,0) - , showbRole -#endif -#if MIN_VERSION_template_haskell(2,8,0) - , showbRuleBndrPrec - , showbRuleMatch -#endif - , showbSafety - , showbStmtPrec - , showbStrict -#if MIN_VERSION_template_haskell(2,8,0) - , showbTyLitPrec -#endif - , showbTypePrec - , showbTyVarBndrPrec -#if MIN_VERSION_template_haskell(2,9,0) - , showbTySynEqnPrec -#endif - , showbDoc - ) where - -import Data.Char (isAlpha) -import Data.Maybe (fromJust) -import Data.Monoid.Compat -import qualified Data.Text.Lazy as TL (Text, dropWhile, null, tail) -import Data.Text.Lazy (uncons) - -#if !(MIN_VERSION_template_haskell(2,10,0)) -import GHC.Exts (Int(I#)) -#endif - -import Language.Haskell.TH.PprLib (Doc, to_HPJ_Doc) -import Language.Haskell.TH.Syntax - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showb, showbPrec), Builder, - fromString, toLazyText) -import Text.Show.Text.Data.Integral (showbIntPrec) -import Text.Show.Text.Text.PrettyPrint (renderB) -import Text.Show.Text.TH (deriveShow) -import Text.Show.Text.Utils (s) - --- | Convert a 'Body' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbBodyPrec :: Int -> Body -> Builder -showbBodyPrec = showbPrec - --- | Convert a 'Callconv' to a 'Builder'. --- --- /Since: 0.1/ -showbCallconv :: Callconv -> Builder -showbCallconv = showb - --- | Convert a 'Clause' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbClausePrec :: Int -> Clause -> Builder -showbClausePrec = showbPrec - --- | Convert a 'Con' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbConPrec :: Int -> Con -> Builder -showbConPrec = showbPrec - --- | Convert a 'Dec' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbDecPrec :: Int -> Dec -> Builder -showbDecPrec = showbPrec - --- | Convert an 'Exp' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbExpPrec :: Int -> Exp -> Builder -showbExpPrec = showbPrec - --- | Convert a 'FamFlavour' to a 'Builder'. --- --- /Since: 0.1/ -showbFamFlavour :: FamFlavour -> Builder -showbFamFlavour = showb - --- | Convert a 'Fixity' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbFixityPrec :: Int -> Fixity -> Builder -showbFixityPrec = showbPrec - --- | Convert a 'FixityDirection' to a 'Builder'. --- --- /Since: 0.1/ -showbFixityDirection :: FixityDirection -> Builder -showbFixityDirection = showb - --- | Convert a 'Foreign' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbForeignPrec :: Int -> Foreign -> Builder -showbForeignPrec = showbPrec - --- | Convert a 'FunDep' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbFunDepPrec :: Int -> FunDep -> Builder -showbFunDepPrec = showbPrec - --- | Convert a 'Guard' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbGuardPrec :: Int -> Guard -> Builder -showbGuardPrec = showbPrec - --- | Convert an 'Info' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbInfoPrec :: Int -> Info -> Builder -showbInfoPrec = showbPrec - --- | Convert a 'Kind' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbKindPrec :: Int -> Kind -> Builder -#if MIN_VERSION_template_haskell(2,8,0) -showbKindPrec = showbTypePrec -#else -showbKindPrec = showbPrec -#endif - --- | Convert a 'Lit' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbLitPrec :: Int -> Dec -> Builder -showbLitPrec = showbPrec - --- | Convert a 'Loc' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbLocPrec :: Int -> Loc -> Builder -showbLocPrec = showbPrec - --- | Convert a 'Match' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMatchPrec :: Int -> Match -> Builder -showbMatchPrec = showbPrec - --- | Convert a 'ModName' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbModNamePrec :: Int -> ModName -> Builder -showbModNamePrec = showbPrec - --- | Convert a 'Name' to a 'Builder'. --- --- /Since: 0.1/ -showbName :: Name -> Builder -showbName = showbName' Alone - --- | Convert a 'Name' to a 'Builder' with the given 'NameIs' settings. --- --- /Since: 0.1/ -showbName' :: NameIs -> Name -> Builder -showbName' ni nm = case ni of - Alone -> nms - Applied - | pnam -> nms - | otherwise -> s '(' <> nms <> s ')' - Infix - | pnam -> s '`' <> nms <> s '`' - | otherwise -> nms - where - -- For now, we make the NameQ and NameG print the same, even though - -- NameQ is a qualified name (so what it means depends on what the - -- current scope is), and NameG is an original name (so its meaning - -- should be independent of what's in scope. - -- We may well want to distinguish them in the end. - -- Ditto NameU and NameL - nms :: Builder - nms = case nm of - Name occ NameS -> occB occ - Name occ (NameQ m) -> modB m <> s '.' <> occB occ - Name occ (NameG _ _ m) -> modB m <> s '.' <> occB occ - Name occ (NameU u) -> occB occ <> s '_' <> showbIntPrec 0 (mkInt u) - Name occ (NameL u) -> occB occ <> s '_' <> showbIntPrec 0 (mkInt u) - -#if MIN_VERSION_template_haskell(2,10,0) - mkInt = id -#else - mkInt i# = I# i# -#endif - - occB :: OccName -> Builder - occB = fromString . occString - - modB :: ModName -> Builder - modB = fromString . modString - - pnam :: Bool - pnam = classify $ toLazyText nms - - -- True if we are function style, e.g. f, [], (,) - -- False if we are operator style, e.g. +, :+ - classify :: TL.Text -> Bool - classify t - | TL.null t = False -- shouldn't happen; . operator is handled below - | otherwise = case fromJust $ uncons t of - (x, xs) -> if isAlpha x || (x `elem` "_[]()") - then let t' = TL.dropWhile (/= '.') xs - in if TL.null t' - then True - else classify $ TL.tail t' - else False - - --- | Convert an 'OccName' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbOccNamePrec :: Int -> OccName -> Builder -showbOccNamePrec = showbPrec - --- | Convert a 'Pat' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbPatPrec :: Int -> Pat -> Builder -showbPatPrec = showbPrec - --- | Convert a 'PkgName' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbPkgNamePrec :: Int -> PkgName -> Builder -showbPkgNamePrec = showbPrec - --- | Convert a 'Pragma' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbPragmaPrec :: Int -> Pragma -> Builder -showbPragmaPrec = showbPrec - --- | Convert a 'Pred' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbPredPrec :: Int -> Pred -> Builder -#if MIN_VERSION_template_haskell(2,10,0) -showbPredPrec = showbTypePrec -#else -showbPredPrec = showbPrec -#endif - --- | Convert a 'Range' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbRangePrec :: Int -> Range -> Builder -showbRangePrec = showbPrec - --- | Convert a 'Safety' to a 'Builder'. --- --- /Since: 0.1/ -showbSafety :: Safety -> Builder -showbSafety = showb - --- | Convert a 'Stmt' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbStmtPrec :: Int -> Stmt -> Builder -showbStmtPrec = showbPrec - --- | Convert a 'Strict' to a 'Builder'. --- --- /Since: 0.1/ -showbStrict :: Strict -> Builder -showbStrict = showb - --- | Convert a 'Type' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTypePrec :: Int -> Type -> Builder -showbTypePrec = showbPrec - --- | Convert a 'TyVarBndr' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTyVarBndrPrec :: Int -> TyVarBndr -> Builder -showbTyVarBndrPrec = showbPrec - --- | Convert a 'Doc' to a 'Builder'. --- --- /Since: 0.3/ -showbDoc :: Doc -> Builder -showbDoc = renderB . to_HPJ_Doc - -#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0)) --- | Convert a 'ClassInstance' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell@ 2.5.0.0 or 2.6.0.0. --- --- /Since: 0.1/ -showbClassInstancePrec :: Int -> ClassInstance -> Builder -showbClassInstancePrec = showbPrec -#endif - -#if MIN_VERSION_template_haskell(2,8,0) --- | Convert an 'Inline' to a 'Builder'. --- This function is only available with @template-haskell-2.8.0.0@ or later. --- --- /Since: 0.1/ -showbInline :: Inline -> Builder -showbInline = showb - --- | Convert a 'Phases' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.8.0.0@ or later. --- --- /Since: 0.1/ -showbPhasesPrec :: Int -> Phases -> Builder -showbPhasesPrec = showbPrec - --- | Convert a 'RuleMatch' to a 'Builder'. --- This function is only available with @template-haskell-2.8.0.0@ or later. --- --- /Since: 0.1/ -showbRuleMatch :: RuleMatch -> Builder -showbRuleMatch = showb - --- | Convert a 'RuleBndr' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.8.0.0@ or later. --- --- /Since: 0.1/ -showbRuleBndrPrec :: Int -> RuleBndr -> Builder -showbRuleBndrPrec = showbPrec - --- | Convert a 'TyLit' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.8.0.0@ or later. --- --- /Since: 0.1/ -showbTyLitPrec :: Int -> TyLit -> Builder -showbTyLitPrec = showbPrec -#else --- | Convert an 'InlineSpec' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.7.0.0@ or earlier. --- --- /Since: 0.1/ -showbInlineSpecPrec :: Int -> InlineSpec -> Builder -showbInlineSpecPrec = showbPrec -#endif - -#if MIN_VERSION_template_haskell(2,9,0) --- | Convert an 'AnnLookup' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbAnnLookupPrec :: Int -> AnnLookup -> Builder -showbAnnLookupPrec = showbPrec - --- | Convert an 'AnnTarget' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbAnnTargetPrec :: Int -> AnnTarget -> Builder -showbAnnTargetPrec = showbPrec - --- | Convert a 'Module' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbModulePrec :: Int -> Module -> Builder -showbModulePrec = showbPrec - --- | Convert a 'ModuleInfo' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbModuleInfoPrec :: Int -> ModuleInfo -> Builder -showbModuleInfoPrec = showbPrec - --- | Convert a 'Role' to a 'Builder'. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbRole :: Role -> Builder -showbRole = showb - --- | Convert a 'TySynEqn' to a 'Builder' with the given precedence. --- This function is only available with @template-haskell-2.9.0.0@ or later. --- --- /Since: 0.1/ -showbTySynEqnPrec :: Int -> TySynEqn -> Builder -showbTySynEqnPrec = showbPrec -#endif - -$(deriveShow ''Body) -$(deriveShow ''Callconv) -$(deriveShow ''Clause) -$(deriveShow ''Con) -$(deriveShow ''Dec) -$(deriveShow ''Exp) -$(deriveShow ''FamFlavour) -$(deriveShow ''Fixity) -$(deriveShow ''FixityDirection) -$(deriveShow ''Foreign) -$(deriveShow ''FunDep) -$(deriveShow ''Guard) -$(deriveShow ''Info) -$(deriveShow ''Lit) -$(deriveShow ''Loc) -$(deriveShow ''Match) -$(deriveShow ''ModName) - -instance Show Name where - showb = showbName - -$(deriveShow ''OccName) -$(deriveShow ''Pat) -$(deriveShow ''PkgName) -$(deriveShow ''Pragma) -$(deriveShow ''Range) -$(deriveShow ''Safety) -$(deriveShow ''Stmt) -$(deriveShow ''Strict) -$(deriveShow ''Type) -$(deriveShow ''TyVarBndr) - -instance Show Doc where - showb = showbDoc - -#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0)) -$(deriveShow ''ClassInstance) -#endif - -#if MIN_VERSION_template_haskell(2,8,0) -$(deriveShow ''Inline) -$(deriveShow ''Phases) -$(deriveShow ''RuleBndr) -$(deriveShow ''RuleMatch) -$(deriveShow ''TyLit) -#else -$(deriveShow ''InlineSpec) -$(deriveShow ''Kind) -#endif - -#if MIN_VERSION_template_haskell(2,9,0) -$(deriveShow ''AnnLookup) -$(deriveShow ''AnnTarget) -$(deriveShow ''Module) -$(deriveShow ''ModuleInfo) -$(deriveShow ''Role) -$(deriveShow ''TySynEqn) -#endif - -#if !(MIN_VERSION_template_haskell(2,10,0)) -$(deriveShow ''Pred) -#endif +{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeSynonymInstances #-}+#if !(MIN_VERSION_template_haskell(2,10,0))+{-# LANGUAGE MagicHash #-}+#endif+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Language.Haskell.TH+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @template-haskell@ library.++/Since: 0.1/+-}+module Text.Show.Text.Language.Haskell.TH (+#if MIN_VERSION_template_haskell(2,9,0)+ showbAnnLookupPrec+ , showbAnnTargetPrec,+#endif+ showbBodyPrec+ , showbCallconv+#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))+ , showbClassInstancePrec+#endif+ , showbClausePrec+ , showbConPrec+ , showbDecPrec+ , showbExpPrec+ , showbFamFlavour+ , showbFixityPrec+ , showbFixityDirection+ , showbForeignPrec+ , showbFunDepPrec+ , showbGuardPrec+ , showbInfoPrec+#if MIN_VERSION_template_haskell(2,8,0)+ , showbInline+#else+ , showbInlineSpecPrec+#endif+ , showbKindPrec+ , showbLitPrec+ , showbLocPrec+ , showbMatchPrec+ , showbModNamePrec+#if MIN_VERSION_template_haskell(2,9,0)+ , showbModulePrec+ , showbModuleInfoPrec+#endif+ , showbName+ , showbName'+ , showbOccNamePrec+ , showbPatPrec+#if MIN_VERSION_template_haskell(2,8,0)+ , showbPhasesPrec+#endif+ , showbPkgNamePrec+ , showbPragmaPrec+ , showbPredPrec+ , showbRangePrec+#if MIN_VERSION_template_haskell(2,9,0)+ , showbRole+#endif+#if MIN_VERSION_template_haskell(2,8,0)+ , showbRuleBndrPrec+ , showbRuleMatch+#endif+ , showbSafety+ , showbStmtPrec+ , showbStrict+#if MIN_VERSION_template_haskell(2,8,0)+ , showbTyLitPrec+#endif+ , showbTypePrec+ , showbTyVarBndrPrec+#if MIN_VERSION_template_haskell(2,9,0)+ , showbTySynEqnPrec+#endif+ , showbDoc+ ) where++import Data.Char (isAlpha)+import Data.Maybe (fromJust)+import Data.Monoid.Compat+import qualified Data.Text.Lazy as TL (Text, dropWhile, null, tail)+import Data.Text.Lazy (uncons)++#if !(MIN_VERSION_template_haskell(2,10,0))+import GHC.Exts (Int(I#))+#endif++import Language.Haskell.TH.PprLib (Doc, to_HPJ_Doc)+import Language.Haskell.TH.Syntax++import Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Builder,+ fromString, singleton, toLazyText)+import Text.Show.Text.Data.Integral (showbIntPrec)+import Text.Show.Text.Text.PrettyPrint (renderB)+import Text.Show.Text.TH (deriveShow)++-- | Convert a 'Body' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbBodyPrec :: Int -> Body -> Builder+showbBodyPrec = showbPrec++-- | Convert a 'Callconv' to a 'Builder'.+--+-- /Since: 0.1/+showbCallconv :: Callconv -> Builder+showbCallconv = showb++-- | Convert a 'Clause' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbClausePrec :: Int -> Clause -> Builder+showbClausePrec = showbPrec++-- | Convert a 'Con' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbConPrec :: Int -> Con -> Builder+showbConPrec = showbPrec++-- | Convert a 'Dec' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbDecPrec :: Int -> Dec -> Builder+showbDecPrec = showbPrec++-- | Convert an 'Exp' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbExpPrec :: Int -> Exp -> Builder+showbExpPrec = showbPrec++-- | Convert a 'FamFlavour' to a 'Builder'.+--+-- /Since: 0.1/+showbFamFlavour :: FamFlavour -> Builder+showbFamFlavour = showb++-- | Convert a 'Fixity' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbFixityPrec :: Int -> Fixity -> Builder+showbFixityPrec = showbPrec++-- | Convert a 'FixityDirection' to a 'Builder'.+--+-- /Since: 0.1/+showbFixityDirection :: FixityDirection -> Builder+showbFixityDirection = showb++-- | Convert a 'Foreign' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbForeignPrec :: Int -> Foreign -> Builder+showbForeignPrec = showbPrec++-- | Convert a 'FunDep' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbFunDepPrec :: Int -> FunDep -> Builder+showbFunDepPrec = showbPrec++-- | Convert a 'Guard' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbGuardPrec :: Int -> Guard -> Builder+showbGuardPrec = showbPrec++-- | Convert an 'Info' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbInfoPrec :: Int -> Info -> Builder+showbInfoPrec = showbPrec++-- | Convert a 'Kind' to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbKindPrec :: Int -> Kind -> Builder+#if MIN_VERSION_template_haskell(2,8,0)+showbKindPrec = showbTypePrec+#else+showbKindPrec = showbPrec+#endif++-- | Convert a 'Lit' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbLitPrec :: Int -> Dec -> Builder+showbLitPrec = showbPrec++-- | Convert a 'Loc' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbLocPrec :: Int -> Loc -> Builder+showbLocPrec = showbPrec++-- | Convert a 'Match' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbMatchPrec :: Int -> Match -> Builder+showbMatchPrec = showbPrec++-- | Convert a 'ModName' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbModNamePrec :: Int -> ModName -> Builder+showbModNamePrec = showbPrec++-- | Convert a 'Name' to a 'Builder'.+--+-- /Since: 0.1/+showbName :: Name -> Builder+showbName = showbName' Alone++-- | Convert a 'Name' to a 'Builder' with the given 'NameIs' settings.+--+-- /Since: 0.1/+showbName' :: NameIs -> Name -> Builder+showbName' ni nm = case ni of+ Alone -> nms+ Applied+ | pnam -> nms+ | otherwise -> singleton '(' <> nms <> singleton ')'+ Infix+ | pnam -> singleton '`' <> nms <> singleton '`'+ | otherwise -> nms+ where+ -- For now, we make the NameQ and NameG print the same, even though+ -- NameQ is a qualified name (so what it means depends on what the+ -- current scope is), and NameG is an original name (so its meaning+ -- should be independent of what's in scope.+ -- We may well want to distinguish them in the end.+ -- Ditto NameU and NameL+ nms :: Builder+ nms = case nm of+ Name occ NameS -> occB occ+ Name occ (NameQ m) -> modB m <> singleton '.' <> occB occ+ Name occ (NameG _ _ m) -> modB m <> singleton '.' <> occB occ+ Name occ (NameU u) -> occB occ <> singleton '_' <> showbIntPrec 0 (mkInt u)+ Name occ (NameL u) -> occB occ <> singleton '_' <> showbIntPrec 0 (mkInt u)++#if MIN_VERSION_template_haskell(2,10,0)+ mkInt = id+#else+ mkInt i# = I# i#+#endif++ occB :: OccName -> Builder+ occB = fromString . occString++ modB :: ModName -> Builder+ modB = fromString . modString++ pnam :: Bool+ pnam = classify $ toLazyText nms++ -- True if we are function style, e.g. f, [], (,)+ -- False if we are operator style, e.g. +, :++ classify :: TL.Text -> Bool+ classify t+ | TL.null t = False -- shouldn't happen; . operator is handled below+ | otherwise = case fromJust $ uncons t of+ (x, xs) -> if isAlpha x || (x `elem` "_[]()")+ then let t' = TL.dropWhile (/= '.') xs+ in if TL.null t'+ then True+ else classify $ TL.tail t'+ else False+++-- | Convert an 'OccName' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbOccNamePrec :: Int -> OccName -> Builder+showbOccNamePrec = showbPrec++-- | Convert a 'Pat' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbPatPrec :: Int -> Pat -> Builder+showbPatPrec = showbPrec++-- | Convert a 'PkgName' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbPkgNamePrec :: Int -> PkgName -> Builder+showbPkgNamePrec = showbPrec++-- | Convert a 'Pragma' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbPragmaPrec :: Int -> Pragma -> Builder+showbPragmaPrec = showbPrec++-- | Convert a 'Pred' to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbPredPrec :: Int -> Pred -> Builder+#if MIN_VERSION_template_haskell(2,10,0)+showbPredPrec = showbTypePrec+#else+showbPredPrec = showbPrec+#endif++-- | Convert a 'Range' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbRangePrec :: Int -> Range -> Builder+showbRangePrec = showbPrec++-- | Convert a 'Safety' to a 'Builder'.+--+-- /Since: 0.1/+showbSafety :: Safety -> Builder+showbSafety = showb++-- | Convert a 'Stmt' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbStmtPrec :: Int -> Stmt -> Builder+showbStmtPrec = showbPrec++-- | Convert a 'Strict' to a 'Builder'.+--+-- /Since: 0.1/+showbStrict :: Strict -> Builder+showbStrict = showb++-- | Convert a 'Type' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbTypePrec :: Int -> Type -> Builder+showbTypePrec = showbPrec++-- | Convert a 'TyVarBndr' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbTyVarBndrPrec :: Int -> TyVarBndr -> Builder+showbTyVarBndrPrec = showbPrec++-- | Convert a 'Doc' to a 'Builder'.+--+-- /Since: 0.3/+showbDoc :: Doc -> Builder+showbDoc = renderB . to_HPJ_Doc++#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))+-- | Convert a 'ClassInstance' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell@ 2.5.0.0 or 2.6.0.0.+--+-- /Since: 0.1/+showbClassInstancePrec :: Int -> ClassInstance -> Builder+showbClassInstancePrec = showbPrec+#endif++#if MIN_VERSION_template_haskell(2,8,0)+-- | Convert an 'Inline' to a 'Builder'.+-- This function is only available with @template-haskell-2.8.0.0@ or later.+--+-- /Since: 0.1/+showbInline :: Inline -> Builder+showbInline = showb++-- | Convert a 'Phases' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.8.0.0@ or later.+--+-- /Since: 0.1/+showbPhasesPrec :: Int -> Phases -> Builder+showbPhasesPrec = showbPrec++-- | Convert a 'RuleMatch' to a 'Builder'.+-- This function is only available with @template-haskell-2.8.0.0@ or later.+--+-- /Since: 0.1/+showbRuleMatch :: RuleMatch -> Builder+showbRuleMatch = showb++-- | Convert a 'RuleBndr' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.8.0.0@ or later.+--+-- /Since: 0.1/+showbRuleBndrPrec :: Int -> RuleBndr -> Builder+showbRuleBndrPrec = showbPrec++-- | Convert a 'TyLit' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.8.0.0@ or later.+--+-- /Since: 0.1/+showbTyLitPrec :: Int -> TyLit -> Builder+showbTyLitPrec = showbPrec+#else+-- | Convert an 'InlineSpec' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.7.0.0@ or earlier.+--+-- /Since: 0.1/+showbInlineSpecPrec :: Int -> InlineSpec -> Builder+showbInlineSpecPrec = showbPrec+#endif++#if MIN_VERSION_template_haskell(2,9,0)+-- | Convert an 'AnnLookup' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbAnnLookupPrec :: Int -> AnnLookup -> Builder+showbAnnLookupPrec = showbPrec++-- | Convert an 'AnnTarget' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbAnnTargetPrec :: Int -> AnnTarget -> Builder+showbAnnTargetPrec = showbPrec++-- | Convert a 'Module' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbModulePrec :: Int -> Module -> Builder+showbModulePrec = showbPrec++-- | Convert a 'ModuleInfo' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbModuleInfoPrec :: Int -> ModuleInfo -> Builder+showbModuleInfoPrec = showbPrec++-- | Convert a 'Role' to a 'Builder'.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbRole :: Role -> Builder+showbRole = showb++-- | Convert a 'TySynEqn' to a 'Builder' with the given precedence.+-- This function is only available with @template-haskell-2.9.0.0@ or later.+--+-- /Since: 0.1/+showbTySynEqnPrec :: Int -> TySynEqn -> Builder+showbTySynEqnPrec = showbPrec+#endif++$(deriveShow ''Body)+$(deriveShow ''Callconv)+$(deriveShow ''Clause)+$(deriveShow ''Con)+$(deriveShow ''Dec)+$(deriveShow ''Exp)+$(deriveShow ''FamFlavour)+$(deriveShow ''Fixity)+$(deriveShow ''FixityDirection)+$(deriveShow ''Foreign)+$(deriveShow ''FunDep)+$(deriveShow ''Guard)+$(deriveShow ''Info)+$(deriveShow ''Lit)+$(deriveShow ''Loc)+$(deriveShow ''Match)+$(deriveShow ''ModName)++instance Show Name where+ showb = showbName++$(deriveShow ''OccName)+$(deriveShow ''Pat)+$(deriveShow ''PkgName)+$(deriveShow ''Pragma)+$(deriveShow ''Range)+$(deriveShow ''Safety)+$(deriveShow ''Stmt)+$(deriveShow ''Strict)+$(deriveShow ''Type)+$(deriveShow ''TyVarBndr)++instance Show Doc where+ showb = showbDoc++#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))+$(deriveShow ''ClassInstance)+#endif++#if MIN_VERSION_template_haskell(2,8,0)+$(deriveShow ''Inline)+$(deriveShow ''Phases)+$(deriveShow ''RuleBndr)+$(deriveShow ''RuleMatch)+$(deriveShow ''TyLit)+#else+$(deriveShow ''InlineSpec)+$(deriveShow ''Kind)+#endif++#if MIN_VERSION_template_haskell(2,9,0)+$(deriveShow ''AnnLookup)+$(deriveShow ''AnnTarget)+$(deriveShow ''Module)+$(deriveShow ''ModuleInfo)+$(deriveShow ''Role)+$(deriveShow ''TySynEqn)+#endif++#if !(MIN_VERSION_template_haskell(2,10,0))+$(deriveShow ''Pred)+#endif
src/Text/Show/Text/System/Console/Haskeline.hs view
@@ -1,73 +1,74 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.System.Console.Haskeline -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @haskeline@ library. - -/Since: 0.2/ --} -module Text.Show.Text.System.Console.Haskeline ( - showbInterrupt - , showbPrefsPrec - , showbCompletionPrec - , showbHistory - ) where - -import Prelude hiding (Show) - -import System.Console.Haskeline (Interrupt, Prefs) -import System.Console.Haskeline.Completion (Completion) -import System.Console.Haskeline.History (History, historyLines) - -import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..), showbUnary) -import Text.Show.Text.TH (deriveShow, deriveShowPragmas, defaultInlineShowb) - -#include "inline.h" - --- | Convert an 'Interrupt' to a 'Builder'. --- --- /Since: 0.2/ -showbInterrupt :: Interrupt -> Builder -showbInterrupt = showb -{-# INLINE showbInterrupt #-} - --- | Convert a 'Prefs' value to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbPrefsPrec :: Int -> Prefs -> Builder -showbPrefsPrec p = showbPrec p . FromStringShow -{-# INLINE showbPrefsPrec #-} - --- | Convert a 'Completion' value to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbCompletionPrec :: Int -> Completion -> Builder -showbCompletionPrec = showbPrec -{-# INLINE showbCompletionPrec #-} - --- | Convert a 'History' value to a 'Builder'. --- --- /Since: 0.2/ -showbHistory :: History -> Builder -showbHistory = showbUnary "fromList" 0 . historyLines -{-# INLINE showbHistory #-} - -$(deriveShowPragmas defaultInlineShowb ''Interrupt) - -instance Show Prefs where - showbPrec = showbPrefsPrec - INLINE_INST_FUN(showbPrec) - -$(deriveShow ''Completion) - -instance Show History where - showb = showbHistory - INLINE_INST_FUN(showb) +{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.System.Console.Haskeline+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @haskeline@ library.++/Since: 0.2/+-}+module Text.Show.Text.System.Console.Haskeline (+ showbInterrupt+ , showbPrefsPrec+ , showbCompletionPrec+ , showbHistory+ ) where++import Prelude hiding (Show)++import System.Console.Haskeline (Interrupt, Prefs)+import System.Console.Haskeline.Completion (Completion)+import System.Console.Haskeline.History (History, historyLines)++import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..))+import Text.Show.Text.TH (deriveShow)+import Text.Show.Text.Utils (showbUnaryListWith)++#include "inline.h"++-- | Convert an 'Interrupt' to a 'Builder'.+--+-- /Since: 0.2/+showbInterrupt :: Interrupt -> Builder+showbInterrupt = showb+{-# INLINE showbInterrupt #-}++-- | Convert a 'Prefs' value to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbPrefsPrec :: Int -> Prefs -> Builder+showbPrefsPrec p = showbPrec p . FromStringShow+{-# INLINE showbPrefsPrec #-}++-- | Convert a 'Completion' value to a 'Builder' with the given precedence.+--+-- /Since: 0.2/+showbCompletionPrec :: Int -> Completion -> Builder+showbCompletionPrec = showbPrec+{-# INLINE showbCompletionPrec #-}++-- | Convert a 'History' value to a 'Builder'.+--+-- /Since: 0.2/+showbHistory :: History -> Builder+showbHistory = showbUnaryListWith showb 0 . historyLines+{-# INLINE showbHistory #-}++$(deriveShow ''Interrupt)++instance Show Prefs where+ showbPrec = showbPrefsPrec+ INLINE_INST_FUN(showbPrec)++$(deriveShow ''Completion)++instance Show History where+ showb = showbHistory+ INLINE_INST_FUN(showb)
src/Text/Show/Text/System/Console/Terminfo.hs view
@@ -1,58 +1,58 @@-{-# LANGUAGE CPP #-} - -#if !defined(mingw32_HOST_OS) -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Text.Show.Text.System.Console.Terminfo -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @terminfo@ library. This module -only exports functions if using a Unix-like operating system (i.e., not Windows). - -/Since: 0.2/ --} -module Text.Show.Text.System.Console.Terminfo ( -#if defined(mingw32_HOST_OS) - ) where -#else - showbColorPrec - , showbSetupTermError - ) where - -import Prelude hiding (Show) - -import System.Console.Terminfo.Base (SetupTermError) -import System.Console.Terminfo.Color (Color) - -import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..)) -import Text.Show.Text.TH (deriveShow) - -#include "inline.h" - --- | Convert a 'Color' to a 'Builder' with the given precedence. --- --- /Since: 0.2/ -showbColorPrec :: Int -> Color -> Builder -showbColorPrec = showbPrec -{-# INLINE showbColorPrec #-} - --- | Convert a 'SetupTermError' to a 'Builder'. --- --- /Since: 0.2/ -showbSetupTermError :: SetupTermError -> Builder -showbSetupTermError = showb . FromStringShow -{-# INLINE showbSetupTermError #-} - -$(deriveShow ''Color) - -instance Show SetupTermError where - showb = showbSetupTermError - INLINE_INST_FUN(showb) -#endif +{-# LANGUAGE CPP #-}++#if !defined(mingw32_HOST_OS)+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Text.Show.Text.System.Console.Terminfo+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @terminfo@ library. This module+only exports functions if using a Unix-like operating system (i.e., not Windows).++/Since: 0.2/+-}+module Text.Show.Text.System.Console.Terminfo (+#if defined(mingw32_HOST_OS)+ ) where+#else+ showbColorPrec+ , showbSetupTermError+ ) where++import Prelude hiding (Show)++import System.Console.Terminfo.Base (SetupTermError)+import System.Console.Terminfo.Color (Color)++import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..))+import Text.Show.Text.TH (deriveShow)++#include "inline.h"++-- | Convert a 'Color' to a 'Builder' with the given precedence.+-- +-- /Since: 0.2/+showbColorPrec :: Int -> Color -> Builder+showbColorPrec = showbPrec+{-# INLINE showbColorPrec #-}++-- | Convert a 'SetupTermError' to a 'Builder'.+-- +-- /Since: 0.2/+showbSetupTermError :: SetupTermError -> Builder+showbSetupTermError = showb . FromStringShow+{-# INLINE showbSetupTermError #-}++$(deriveShow ''Color)++instance Show SetupTermError where+ showb = showbSetupTermError+ INLINE_INST_FUN(showb)+#endif
src/Text/Show/Text/System/Directory.hs view
@@ -1,31 +1,31 @@-{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.System.Directory -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'Permissions'. - -/Since: 0.1/ --} -module Text.Show.Text.System.Directory (showbPermissionsPrec) where - -import Prelude hiding (Show) - -import System.Directory (Permissions) - -import Text.Show.Text (Show(showbPrec), Builder) -import Text.Show.Text.TH (deriveShow) - --- | Convert 'Permissions' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbPermissionsPrec :: Int -> Permissions -> Builder -showbPermissionsPrec = showbPrec -{-# INLINE showbPermissionsPrec #-} - +{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.System.Directory+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for 'Permissions'.++/Since: 0.1/+-}+module Text.Show.Text.System.Directory (showbPermissionsPrec) where++import Prelude hiding (Show)++import System.Directory (Permissions)++import Text.Show.Text (Show(showbPrec), Builder)+import Text.Show.Text.TH (deriveShow)++-- | Convert 'Permissions' to a 'Builder' with the given precedence.+-- +-- /Since: 0.1/+showbPermissionsPrec :: Int -> Permissions -> Builder+showbPermissionsPrec = showbPrec+{-# INLINE showbPermissionsPrec #-}+ $(deriveShow ''Permissions)
src/Text/Show/Text/System/Locale.hs view
@@ -1,31 +1,31 @@-{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.System.Locale -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for old 'TimeLocale's. - -/Since: 0.1/ --} -module Text.Show.Text.System.Locale (showbTimeLocalePrec) where - -import System.Locale (TimeLocale) - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showbPrec), Builder) -import Text.Show.Text.TH (deriveShow) - --- | Convert a 'TimeLocale' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTimeLocalePrec :: Int -> TimeLocale -> Builder -showbTimeLocalePrec = showbPrec -{-# INLINE showbTimeLocalePrec #-} - +{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.System.Locale+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for old 'TimeLocale's.++/Since: 0.1/+-}+module Text.Show.Text.System.Locale (showbTimeLocalePrec) where++import System.Locale (TimeLocale)++import Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Builder)+import Text.Show.Text.TH (deriveShow)++-- | Convert a 'TimeLocale' to a 'Builder' with the given precedence.+-- +-- /Since: 0.1/+showbTimeLocalePrec :: Int -> TimeLocale -> Builder+showbTimeLocalePrec = showbPrec+{-# INLINE showbTimeLocalePrec #-}+ $(deriveShow ''TimeLocale)
src/Text/Show/Text/System/Posix.hs view
@@ -1,79 +1,79 @@-{-# LANGUAGE CPP #-} - -#if !defined(mingw32_HOST_OS) -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Text.Show.Text.System.Posix -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @unix@ library. This module -only exports functions if using a Unix-like operating system (i.e., not Windows). - -/Since: 0.1/ --} -module Text.Show.Text.System.Posix ( -#if defined(mingw32_HOST_OS) - ) where -#else - showbRTLDFlags - , showbDLPrec - , showbProcessStatusPrec - , showbGroupEntryPrec - , showbUserEntryPrec - ) where - -import System.Posix.DynamicLinker (RTLDFlags, DL) -import System.Posix.Process (ProcessStatus) -import System.Posix.User (GroupEntry, UserEntry) - -import Text.Show.Text (Builder, showb, showbPrec) -import Text.Show.Text.TH (deriveShow, deriveShowPragmas, defaultInlineShowb) - --- | Convert an 'RTLDFlags' value to a 'Builder'. --- --- /Since: 0.1/ -showbRTLDFlags :: RTLDFlags -> Builder -showbRTLDFlags = showb -{-# INLINE showbRTLDFlags #-} - --- | Convert a 'DL' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbDLPrec :: Int -> DL -> Builder -showbDLPrec = showbPrec -{-# INLINE showbDLPrec #-} - --- | Convert a 'ProcessStatus' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbProcessStatusPrec :: Int -> ProcessStatus -> Builder -showbProcessStatusPrec = showbPrec -{-# INLINE showbProcessStatusPrec #-} - --- | Convert a 'GroupEntry' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbGroupEntryPrec :: Int -> GroupEntry -> Builder -showbGroupEntryPrec = showbPrec -{-# INLINE showbGroupEntryPrec #-} - --- | Convert a 'UserEntry' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbUserEntryPrec :: Int -> UserEntry -> Builder -showbUserEntryPrec = showbPrec -{-# INLINE showbUserEntryPrec #-} - -$(deriveShowPragmas defaultInlineShowb ''RTLDFlags) -$(deriveShow ''DL) -$(deriveShow ''ProcessStatus) -$(deriveShow ''GroupEntry) -$(deriveShow ''UserEntry) -#endif +{-# LANGUAGE CPP #-}++#if !defined(mingw32_HOST_OS)+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Text.Show.Text.System.Posix+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @unix@ library. This module+only exports functions if using a Unix-like operating system (i.e., not Windows).++/Since: 0.1/+-}+module Text.Show.Text.System.Posix (+#if defined(mingw32_HOST_OS)+ ) where+#else+ showbRTLDFlags+ , showbDLPrec+ , showbProcessStatusPrec+ , showbGroupEntryPrec+ , showbUserEntryPrec+ ) where++import System.Posix.DynamicLinker (RTLDFlags, DL)+import System.Posix.Process (ProcessStatus)+import System.Posix.User (GroupEntry, UserEntry)++import Text.Show.Text (Builder, showb, showbPrec)+import Text.Show.Text.TH (deriveShow)++-- | Convert an 'RTLDFlags' value to a 'Builder'.+--+-- /Since: 0.1/+showbRTLDFlags :: RTLDFlags -> Builder+showbRTLDFlags = showb+{-# INLINE showbRTLDFlags #-}++-- | Convert a 'DL' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbDLPrec :: Int -> DL -> Builder+showbDLPrec = showbPrec+{-# INLINE showbDLPrec #-}++-- | Convert a 'ProcessStatus' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbProcessStatusPrec :: Int -> ProcessStatus -> Builder+showbProcessStatusPrec = showbPrec+{-# INLINE showbProcessStatusPrec #-}++-- | Convert a 'GroupEntry' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbGroupEntryPrec :: Int -> GroupEntry -> Builder+showbGroupEntryPrec = showbPrec+{-# INLINE showbGroupEntryPrec #-}++-- | Convert a 'UserEntry' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbUserEntryPrec :: Int -> UserEntry -> Builder+showbUserEntryPrec = showbPrec+{-# INLINE showbUserEntryPrec #-}++$(deriveShow ''RTLDFlags)+$(deriveShow ''DL)+$(deriveShow ''ProcessStatus)+$(deriveShow ''GroupEntry)+$(deriveShow ''UserEntry)+#endif
src/Text/Show/Text/System/Random.hs view
@@ -1,32 +1,32 @@-{-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.System.Random -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' function for 'StdGen'. - -/Since: 0.1/ --} -module Text.Show.Text.System.Random (showbStdGenPrec) where - -import Prelude hiding (Show) -import System.Random (StdGen) -import Text.Show.Text (Show(showbPrec), Builder, FromStringShow(..)) - -#include "inline.h" - --- | Convert a 'StdGen' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbStdGenPrec :: Int -> StdGen -> Builder -showbStdGenPrec p = showbPrec p . FromStringShow -{-# INLINE showbStdGenPrec #-} - -instance Show StdGen where - showbPrec = showbStdGenPrec +{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.System.Random+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' function for 'StdGen'.++/Since: 0.1/+-}+module Text.Show.Text.System.Random (showbStdGenPrec) where++import Prelude hiding (Show)+import System.Random (StdGen)+import Text.Show.Text (Show(showbPrec), Builder, FromStringShow(..))++#include "inline.h"++-- | Convert a 'StdGen' to a 'Builder' with the given precedence.+-- +-- /Since: 0.1/+showbStdGenPrec :: Int -> StdGen -> Builder+showbStdGenPrec p = showbPrec p . FromStringShow+{-# INLINE showbStdGenPrec #-}++instance Show StdGen where+ showbPrec = showbStdGenPrec INLINE_INST_FUN(showbPrec)
src/Text/Show/Text/System/Time.hs view
@@ -1,76 +1,76 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.System.Time -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @old-time@ library. - -/Since: 0.1/ --} -module Text.Show.Text.System.Time ( - showbClockTime - , showbTimeDiffPrec - , showbCalendarTimePrec - , showbMonth - , showbDay - ) where - -import Prelude hiding (Show) - -import System.IO.Unsafe (unsafePerformIO) -import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day, - calendarTimeToString, toCalendarTime) - -import Text.Show.Text (Show(showb, showbPrec), Builder, fromString) -import Text.Show.Text.TH (deriveShow) - -#include "inline.h" - --- | Convert a 'ClockTime' to a 'Builder'. --- --- /Since: 0.1/ -showbClockTime :: ClockTime -> Builder -showbClockTime = fromString . calendarTimeToString . unsafePerformIO . toCalendarTime - --- | Convert a 'TimeDiff' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTimeDiffPrec :: Int -> TimeDiff -> Builder -showbTimeDiffPrec = showbPrec -{-# INLINE showbTimeDiffPrec #-} - --- | Convert a 'CalendarTime' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbCalendarTimePrec :: Int -> CalendarTime -> Builder -showbCalendarTimePrec = showbPrec -{-# INLINE showbCalendarTimePrec #-} - --- | Convert a 'Month' to a 'Builder'. --- --- /Since: 0.1/ -showbMonth :: Month -> Builder -showbMonth = showb -{-# INLINE showbMonth #-} - --- | Convert a 'Day' to a 'Builder'. --- --- /Since: 0.1/ -showbDay :: Day -> Builder -showbDay = showb -{-# INLINE showbDay #-} - -instance Show ClockTime where - showb = showbClockTime - INLINE_INST_FUN(showb) - -$(deriveShow ''TimeDiff) -$(deriveShow ''CalendarTime) -$(deriveShow ''Month) -$(deriveShow ''Day) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.System.Time+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @old-time@ library.++/Since: 0.1/+-}+module Text.Show.Text.System.Time (+ showbClockTime+ , showbTimeDiffPrec+ , showbCalendarTimePrec+ , showbMonth+ , showbDay+ ) where++import Prelude hiding (Show)++import System.IO.Unsafe (unsafePerformIO)+import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day,+ calendarTimeToString, toCalendarTime)++import Text.Show.Text (Show(showb, showbPrec), Builder, fromString)+import Text.Show.Text.TH (deriveShow)++#include "inline.h"++-- | Convert a 'ClockTime' to a 'Builder'.+-- +-- /Since: 0.1/+showbClockTime :: ClockTime -> Builder+showbClockTime = fromString . calendarTimeToString . unsafePerformIO . toCalendarTime++-- | Convert a 'TimeDiff' to a 'Builder' with the given precedence.+-- +-- /Since: 0.1/+showbTimeDiffPrec :: Int -> TimeDiff -> Builder+showbTimeDiffPrec = showbPrec+{-# INLINE showbTimeDiffPrec #-}++-- | Convert a 'CalendarTime' to a 'Builder' with the given precedence.+-- +-- /Since: 0.1/+showbCalendarTimePrec :: Int -> CalendarTime -> Builder+showbCalendarTimePrec = showbPrec+{-# INLINE showbCalendarTimePrec #-}++-- | Convert a 'Month' to a 'Builder'.+-- +-- /Since: 0.1/+showbMonth :: Month -> Builder+showbMonth = showb+{-# INLINE showbMonth #-}++-- | Convert a 'Day' to a 'Builder'.+-- +-- /Since: 0.1/+showbDay :: Day -> Builder+showbDay = showb+{-# INLINE showbDay #-}++instance Show ClockTime where+ showb = showbClockTime+ INLINE_INST_FUN(showb)++$(deriveShow ''TimeDiff)+$(deriveShow ''CalendarTime)+$(deriveShow ''Month)+$(deriveShow ''Day)
src/Text/Show/Text/System/Win32.hs view
@@ -1,126 +1,125 @@-{-# LANGUAGE CPP #-} - -#if defined(mingw32_HOST_OS) -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Text.Show.Text.System.Win32 -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @Win32@ library. -This module only exports functions if using Windows. - -/Since: 0.1/ --} -module Text.Show.Text.System.Win32 ( -#if !defined(mingw32_HOST_OS) - ) where -#else - showbDebugEventInfoPrec - , showbExceptionPrec - , showb_BY_HANDLE_FILE_INFORMATION_Prec - , showb_WIN32_FILE_ATTRIBUTE_DATA_Prec - , showbProcessorArchitecturePrec - , showb_SYSTEM_INFO_Prec - , showb_FILETIME_Prec - , showb_SYSTEMTIME_Prec - , showb_TIME_ZONE_INFORMATION_Prec - , showbTimeZoneIdPrec - ) where - -import System.Win32.DebugApi (DebugEventInfo, Exception) -import System.Win32.File (BY_HANDLE_FILE_INFORMATION, WIN32_FILE_ATTRIBUTE_DATA) -import System.Win32.Info (ProcessorArchitecture, SYSTEM_INFO) -import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId) - -import Text.Show.Text (Builder, showb, showbPrec) -import Text.Show.Text.TH (deriveShow, deriveShowPragmas, - defaultInlineShowb, defaultInlineShowbPrec) - --- | Convert a 'DebugEventInfo' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbDebugEventInfoPrec :: Int -> DebugEventInfo -> Builder -showbDebugEventInfoPrec = showbPrec -{-# INLINE showbDebugEventInfoPrec #-} - --- | Convert an 'Exception' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbExceptionPrec :: Int -> Exception -> Builder -showbExceptionPrec = showbPrec -{-# INLINE showbExceptionPrec #-} - --- | Convert a 'BY_HANDLE_FILE_INFORMATION' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_BY_HANDLE_FILE_INFORMATION_Prec :: Int -> BY_HANDLE_FILE_INFORMATION -> Builder -showb_BY_HANDLE_FILE_INFORMATION_Prec = showbPrec -{-# INLINE showb_BY_HANDLE_FILE_INFORMATION_Prec #-} - --- | Convert a 'WIN32_FILE_ATTRIBUTE_DATA' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_WIN32_FILE_ATTRIBUTE_DATA_Prec :: Int -> WIN32_FILE_ATTRIBUTE_DATA -> Builder -showb_WIN32_FILE_ATTRIBUTE_DATA_Prec = showbPrec -{-# INLINE showb_WIN32_FILE_ATTRIBUTE_DATA_Prec #-} - --- | Convert a 'ProcessorArchitecture' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbProcessorArchitecturePrec :: Int -> ProcessorArchitecture -> Builder -showbProcessorArchitecturePrec = showbPrec -{-# INLINE showbProcessorArchitecturePrec #-} - --- | Convert a 'SYSTEM_INFO' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_SYSTEM_INFO_Prec :: Int -> SYSTEM_INFO -> Builder -showb_SYSTEM_INFO_Prec = showbPrec -{-# INLINE showb_SYSTEM_INFO_Prec #-} - --- | Convert a 'FILETIME' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_FILETIME_Prec :: Int -> FILETIME -> Builder -showb_FILETIME_Prec = showbPrec -{-# INLINE showb_FILETIME_Prec #-} - --- | Convert a 'SYSTEMTIME' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_SYSTEMTIME_Prec :: Int -> SYSTEMTIME -> Builder -showb_SYSTEMTIME_Prec = showbPrec -{-# INLINE showb_SYSTEMTIME_Prec #-} - --- | Convert a 'TIME_ZONE_INFORMATION' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showb_TIME_ZONE_INFORMATION_Prec :: Int -> TIME_ZONE_INFORMATION -> Builder -showb_TIME_ZONE_INFORMATION_Prec = showbPrec -{-# INLINE showb_TIME_ZONE_INFORMATION_Prec #-} - --- | Convert a 'TimeZoneId' to a 'Builder'. --- --- /Since: 0.1/ -showbTimeZoneIdPrec :: TimeZoneId -> Builder -showbTimeZoneIdPrec = showb -{-# INLINE showbTimeZoneIdPrec #-} - -$(deriveShow ''DebugEventInfo) -$(deriveShow ''Exception) -$(deriveShow ''BY_HANDLE_FILE_INFORMATION) -$(deriveShow ''WIN32_FILE_ATTRIBUTE_DATA) -$(deriveShow ''ProcessorArchitecture) -$(deriveShow ''SYSTEM_INFO) -$(deriveShowPragmas defaultInlineShowbPrec ''FILETIME) -$(deriveShow ''SYSTEMTIME) -$(deriveShow ''TIME_ZONE_INFORMATION) -$(deriveShowPragmas defaultInlineShowb ''TimeZoneId) -#endif +{-# LANGUAGE CPP #-}++#if defined(mingw32_HOST_OS)+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Text.Show.Text.System.Win32+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @Win32@ library.+This module only exports functions if using Windows.++/Since: 0.1/+-}+module Text.Show.Text.System.Win32 (+#if !defined(mingw32_HOST_OS)+ ) where+#else+ showbDebugEventInfoPrec+ , showbExceptionPrec+ , showb_BY_HANDLE_FILE_INFORMATION_Prec+ , showb_WIN32_FILE_ATTRIBUTE_DATA_Prec+ , showbProcessorArchitecturePrec+ , showb_SYSTEM_INFO_Prec+ , showb_FILETIME_Prec+ , showb_SYSTEMTIME_Prec+ , showb_TIME_ZONE_INFORMATION_Prec+ , showbTimeZoneIdPrec+ ) where++import System.Win32.DebugApi (DebugEventInfo, Exception)+import System.Win32.File (BY_HANDLE_FILE_INFORMATION, WIN32_FILE_ATTRIBUTE_DATA)+import System.Win32.Info (ProcessorArchitecture, SYSTEM_INFO)+import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId)++import Text.Show.Text (Builder, showb, showbPrec)+import Text.Show.Text.TH (deriveShow)++-- | Convert a 'DebugEventInfo' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbDebugEventInfoPrec :: Int -> DebugEventInfo -> Builder+showbDebugEventInfoPrec = showbPrec+{-# INLINE showbDebugEventInfoPrec #-}++-- | Convert an 'Exception' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbExceptionPrec :: Int -> Exception -> Builder+showbExceptionPrec = showbPrec+{-# INLINE showbExceptionPrec #-}++-- | Convert a 'BY_HANDLE_FILE_INFORMATION' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_BY_HANDLE_FILE_INFORMATION_Prec :: Int -> BY_HANDLE_FILE_INFORMATION -> Builder+showb_BY_HANDLE_FILE_INFORMATION_Prec = showbPrec+{-# INLINE showb_BY_HANDLE_FILE_INFORMATION_Prec #-}++-- | Convert a 'WIN32_FILE_ATTRIBUTE_DATA' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_WIN32_FILE_ATTRIBUTE_DATA_Prec :: Int -> WIN32_FILE_ATTRIBUTE_DATA -> Builder+showb_WIN32_FILE_ATTRIBUTE_DATA_Prec = showbPrec+{-# INLINE showb_WIN32_FILE_ATTRIBUTE_DATA_Prec #-}++-- | Convert a 'ProcessorArchitecture' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbProcessorArchitecturePrec :: Int -> ProcessorArchitecture -> Builder+showbProcessorArchitecturePrec = showbPrec+{-# INLINE showbProcessorArchitecturePrec #-}++-- | Convert a 'SYSTEM_INFO' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_SYSTEM_INFO_Prec :: Int -> SYSTEM_INFO -> Builder+showb_SYSTEM_INFO_Prec = showbPrec+{-# INLINE showb_SYSTEM_INFO_Prec #-}++-- | Convert a 'FILETIME' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_FILETIME_Prec :: Int -> FILETIME -> Builder+showb_FILETIME_Prec = showbPrec+{-# INLINE showb_FILETIME_Prec #-}++-- | Convert a 'SYSTEMTIME' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_SYSTEMTIME_Prec :: Int -> SYSTEMTIME -> Builder+showb_SYSTEMTIME_Prec = showbPrec+{-# INLINE showb_SYSTEMTIME_Prec #-}++-- | Convert a 'TIME_ZONE_INFORMATION' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showb_TIME_ZONE_INFORMATION_Prec :: Int -> TIME_ZONE_INFORMATION -> Builder+showb_TIME_ZONE_INFORMATION_Prec = showbPrec+{-# INLINE showb_TIME_ZONE_INFORMATION_Prec #-}++-- | Convert a 'TimeZoneId' to a 'Builder'.+--+-- /Since: 0.1/+showbTimeZoneIdPrec :: TimeZoneId -> Builder+showbTimeZoneIdPrec = showb+{-# INLINE showbTimeZoneIdPrec #-}++$(deriveShow ''DebugEventInfo)+$(deriveShow ''Exception)+$(deriveShow ''BY_HANDLE_FILE_INFORMATION)+$(deriveShow ''WIN32_FILE_ATTRIBUTE_DATA)+$(deriveShow ''ProcessorArchitecture)+$(deriveShow ''SYSTEM_INFO)+$(deriveShow ''FILETIME)+$(deriveShow ''SYSTEMTIME)+$(deriveShow ''TIME_ZONE_INFORMATION)+$(deriveShow ''TimeZoneId)+#endif
src/Text/Show/Text/Text/PrettyPrint.hs view
@@ -1,109 +1,107 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Text.PrettyPrint -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @pretty@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Text.PrettyPrint ( - renderB - , renderStyleB - , showbMode - , showbStylePrec - , showbTextDetailsPrec -#if MIN_VERSION_pretty(1,1,2) - , showbPrettyLevelPrec -#endif - ) where - -import Data.Monoid.Compat - -import Prelude hiding (Show) - -import Text.PrettyPrint.HughesPJ (Doc, Mode, Style(..), TextDetails(..), - fullRender, style) -#if MIN_VERSION_pretty(1,1,2) -import Text.PrettyPrint.HughesPJClass (PrettyLevel) -import Text.Show.Text.TH (defaultInlineShowbPrec) -#endif -import Text.Show.Text (Show(showb, showbPrec), Builder, fromString) -import Text.Show.Text.TH (deriveShow, deriveShowPragmas, defaultInlineShowb) -import Text.Show.Text.Utils (s) - -#include "inline.h" - --- | Renders a 'Doc' to a 'Builder' using the default 'style'. --- --- /Since: 0.3/ -renderB :: Doc -> Builder -renderB = renderStyleB style -{-# INLINE renderB #-} - --- | Renders a 'Doc' to a 'Builder' using the given 'Style'. --- --- /Since: 0.2/ -renderStyleB :: Style -> Doc -> Builder -renderStyleB sty doc = fullRender (mode sty) - (lineLength sty) - (ribbonsPerLine sty) - txtPrinter - mempty - doc -{-# INLINE renderStyleB #-} - -txtPrinter :: TextDetails -> Builder -> Builder -txtPrinter (Chr c) b = s c <> b -txtPrinter (Str s') b = fromString s' <> b -txtPrinter (PStr s') b = fromString s' <> b -{-# INLINE txtPrinter #-} - --- | Convert a 'Mode' to a 'Builder'. --- --- /Since: 0.1/ -showbMode :: Mode -> Builder -showbMode = showb -{-# INLINE showbMode #-} - --- | Convert a 'Style' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbStylePrec :: Int -> Style -> Builder -showbStylePrec = showbPrec -{-# INLINE showbStylePrec #-} - --- | Convert 'TextDetails' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTextDetailsPrec :: Int -> TextDetails -> Builder -showbTextDetailsPrec = showbPrec -{-# INLINE showbTextDetailsPrec #-} - -#if MIN_VERSION_pretty(1,1,2) --- | Convert a 'PrettyLevel' value to a 'Builder' with the given precedence. --- This function is only available with @pretty-1.1.2.0@ or later. --- --- /Since: 0.1/ -showbPrettyLevelPrec :: Int -> PrettyLevel -> Builder -showbPrettyLevelPrec = showbPrec -{-# INLINE showbPrettyLevelPrec #-} -#endif - -instance Show Doc where - showb = renderB - INLINE_INST_FUN(showb) - -$(deriveShowPragmas defaultInlineShowb ''Mode) -$(deriveShow ''Style) -$(deriveShow ''TextDetails) - -#if MIN_VERSION_pretty(1,1,2) -$(deriveShowPragmas defaultInlineShowbPrec ''PrettyLevel) -#endif +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Text.PrettyPrint+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @pretty@ library.++/Since: 0.1/+-}+module Text.Show.Text.Text.PrettyPrint (+ renderB+ , renderStyleB+ , showbMode+ , showbStylePrec+ , showbTextDetailsPrec+#if MIN_VERSION_pretty(1,1,2)+ , showbPrettyLevelPrec+#endif+ ) where++import Data.Monoid.Compat++import Prelude hiding (Show)++import Text.PrettyPrint.HughesPJ (Doc, Mode, Style(..), TextDetails(..),+ fullRender, style)+#if MIN_VERSION_pretty(1,1,2)+import Text.PrettyPrint.HughesPJClass (PrettyLevel)+#endif+import Text.Show.Text (Show(showb, showbPrec), Builder, fromString, singleton)+import Text.Show.Text.TH (deriveShow)++#include "inline.h"++-- | Renders a 'Doc' to a 'Builder' using the default 'style'.+--+-- /Since: 0.3/+renderB :: Doc -> Builder+renderB = renderStyleB style+{-# INLINE renderB #-}++-- | Renders a 'Doc' to a 'Builder' using the given 'Style'.+--+-- /Since: 0.2/+renderStyleB :: Style -> Doc -> Builder+renderStyleB sty doc = fullRender (mode sty)+ (lineLength sty)+ (ribbonsPerLine sty)+ txtPrinter+ mempty+ doc+{-# INLINE renderStyleB #-}++txtPrinter :: TextDetails -> Builder -> Builder+txtPrinter (Chr c) b = singleton c <> b+txtPrinter (Str s') b = fromString s' <> b+txtPrinter (PStr s') b = fromString s' <> b+{-# INLINE txtPrinter #-}++-- | Convert a 'Mode' to a 'Builder'.+--+-- /Since: 0.1/+showbMode :: Mode -> Builder+showbMode = showb+{-# INLINE showbMode #-}++-- | Convert a 'Style' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbStylePrec :: Int -> Style -> Builder+showbStylePrec = showbPrec+{-# INLINE showbStylePrec #-}++-- | Convert 'TextDetails' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbTextDetailsPrec :: Int -> TextDetails -> Builder+showbTextDetailsPrec = showbPrec+{-# INLINE showbTextDetailsPrec #-}++#if MIN_VERSION_pretty(1,1,2)+-- | Convert a 'PrettyLevel' value to a 'Builder' with the given precedence.+-- This function is only available with @pretty-1.1.2.0@ or later.+--+-- /Since: 0.1/+showbPrettyLevelPrec :: Int -> PrettyLevel -> Builder+showbPrettyLevelPrec = showbPrec+{-# INLINE showbPrettyLevelPrec #-}+#endif++instance Show Doc where+ showb = renderB+ INLINE_INST_FUN(showb)++$(deriveShow ''Mode)+$(deriveShow ''Style)+$(deriveShow ''TextDetails)++#if MIN_VERSION_pretty(1,1,2)+$(deriveShow ''PrettyLevel)+#endif
src/Text/Show/Text/Text/XHtml.hs view
@@ -1,89 +1,88 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Text.XHtml -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @xhtml@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Text.XHtml ( - showbHtml - , showbHtmlList - , showbHtmlAttr - , showbHotLinkPrec - , showbHtmlTable - ) where - -import Data.Monoid.Compat - -import Prelude hiding (Show) - -import Text.Show.Text (Show(..), Builder, FromStringShow(..), fromString) -import Text.Show.Text.Data.Char (showbString) -import Text.Show.Text.TH (deriveShow) -import Text.Show.Text.Utils (s) -import Text.XHtml.Frameset (Html, HtmlAttr, HotLink, - htmlAttrPair, renderHtmlFragment) -import Text.XHtml.Table (HtmlTable) - -#include "inline.h" - --- | Convert an 'Html' value to a 'Builder'. --- --- /Since: 0.1/ -showbHtml :: Html -> Builder -showbHtml = fromString . renderHtmlFragment -{-# INLINE showbHtml #-} - --- | Convert a list of 'Html' values to a 'Builder'. --- --- /Since: 0.1/ -showbHtmlList :: [Html] -> Builder -showbHtmlList = mconcat . map showb -{-# INLINE showbHtmlList #-} - --- | Convert an 'HtmlAttr' to a 'Builder'. --- --- /Since: 0.1/ -showbHtmlAttr :: HtmlAttr -> Builder -showbHtmlAttr ha = case htmlAttrPair ha of - (str, val) -> fromString str <> s '=' <> showbString val -{-# INLINE showbHtmlAttr #-} - --- | Convert a 'HotLink' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbHotLinkPrec :: Int -> HotLink -> Builder -showbHotLinkPrec = showbPrec -{-# INLINE showbHotLinkPrec #-} - --- | Convert an 'HtmlTable' to a 'Builder'. --- --- /Since: 0.1/ -showbHtmlTable :: HtmlTable -> Builder -showbHtmlTable = showb . FromStringShow -{-# INLINE showbHtmlTable #-} - -instance Show Html where - showb = showbHtml - INLINE_INST_FUN(showb) - - showbList = showbHtmlList - INLINE_INST_FUN(showbList) - -instance Show HtmlAttr where - showb = showbHtmlAttr - INLINE_INST_FUN(showb) - -$(deriveShow ''HotLink) - -instance Show HtmlTable where - showb = showbHtmlTable - INLINE_INST_FUN(showb) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Text.XHtml+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @xhtml@ library.++/Since: 0.1/+-}+module Text.Show.Text.Text.XHtml (+ showbHtml+ , showbHtmlList+ , showbHtmlAttr+ , showbHotLinkPrec+ , showbHtmlTable+ ) where++import Data.Monoid.Compat++import Prelude hiding (Show)++import Text.Show.Text (Show(..), Builder, FromStringShow(..), fromString, singleton)+import Text.Show.Text.Data.Char (showbString)+import Text.Show.Text.TH (deriveShow)+import Text.XHtml.Frameset (Html, HtmlAttr, HotLink,+ htmlAttrPair, renderHtmlFragment)+import Text.XHtml.Table (HtmlTable)++#include "inline.h"++-- | Convert an 'Html' value to a 'Builder'.+--+-- /Since: 0.1/+showbHtml :: Html -> Builder+showbHtml = fromString . renderHtmlFragment+{-# INLINE showbHtml #-}++-- | Convert a list of 'Html' values to a 'Builder'.+--+-- /Since: 0.1/+showbHtmlList :: [Html] -> Builder+showbHtmlList = mconcat . map showb+{-# INLINE showbHtmlList #-}++-- | Convert an 'HtmlAttr' to a 'Builder'.+--+-- /Since: 0.1/+showbHtmlAttr :: HtmlAttr -> Builder+showbHtmlAttr ha = case htmlAttrPair ha of+ (str, val) -> fromString str <> singleton '=' <> showbString val+{-# INLINE showbHtmlAttr #-}++-- | Convert a 'HotLink' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbHotLinkPrec :: Int -> HotLink -> Builder+showbHotLinkPrec = showbPrec+{-# INLINE showbHotLinkPrec #-}++-- | Convert an 'HtmlTable' to a 'Builder'.+--+-- /Since: 0.1/+showbHtmlTable :: HtmlTable -> Builder+showbHtmlTable = showb . FromStringShow+{-# INLINE showbHtmlTable #-}++instance Show Html where+ showb = showbHtml+ INLINE_INST_FUN(showb)++ showbList = showbHtmlList+ INLINE_INST_FUN(showbList)++instance Show HtmlAttr where+ showb = showbHtmlAttr+ INLINE_INST_FUN(showb)++$(deriveShow ''HotLink)++instance Show HtmlTable where+ showb = showbHtmlTable+ INLINE_INST_FUN(showb)
src/Text/Show/Text/Trace/Hpc.hs view
@@ -1,108 +1,106 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Text.Show.Text.Trace.Hpc -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Monomorphic 'Show' functions for data types in the @hpc@ library. - -/Since: 0.1/ --} -module Text.Show.Text.Trace.Hpc ( - showbMixPrec - , showbBoxLabelPrec - , showbCondBox - , showbTixPrec - , showbTixModulePrec - , showbHpcPos - , showbHash - ) where - -import Data.Monoid.Compat - -import Prelude hiding (Show) - -import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..)) -import Text.Show.Text.Data.Integral (showbIntPrec) -import Text.Show.Text.Data.Time () -import Text.Show.Text.TH (deriveShow, deriveShowPragmas, - defaultInlineShowb, defaultInlineShowbPrec) -import Text.Show.Text.Utils (s) - -import Trace.Hpc.Mix (Mix, BoxLabel, CondBox) -import Trace.Hpc.Tix (Tix, TixModule) -import Trace.Hpc.Util (HpcPos, Hash, fromHpcPos) - -#include "inline.h" - --- | Convert a 'Mix' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbMixPrec :: Int -> Mix -> Builder -showbMixPrec = showbPrec -{-# INLINE showbMixPrec #-} - --- | Convert a 'BoxLabel' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbBoxLabelPrec :: Int -> BoxLabel -> Builder -showbBoxLabelPrec = showbPrec -{-# INLINE showbBoxLabelPrec #-} - --- | Convert a 'CondBox' to a 'Builder'. --- --- /Since: 0.1/ -showbCondBox :: CondBox -> Builder -showbCondBox = showb -{-# INLINE showbCondBox #-} - --- | Convert a 'Tix' value to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTixPrec :: Int -> Tix -> Builder -showbTixPrec = showbPrec -{-# INLINE showbTixPrec #-} - --- | Convert a 'TixModule' to a 'Builder' with the given precedence. --- --- /Since: 0.1/ -showbTixModulePrec :: Int -> TixModule -> Builder -showbTixModulePrec = showbPrec -{-# INLINE showbTixModulePrec #-} - --- | Convert a 'HpcPos' to a 'Builder'. --- --- /Since: 0.1/ -showbHpcPos :: HpcPos -> Builder -showbHpcPos hp = case fromHpcPos hp of - (l1, c1, l2, c2) -> showbIntPrec 0 l1 - <> (s ':' <> showbIntPrec 0 c1) - <> (s '-' <> showbIntPrec 0 l2) - <> (s ':' <> showbIntPrec 0 c2) -{-# INLINE showbHpcPos #-} - --- | Convert a 'Hash' to a 'Builder'. --- --- /Since: 0.1/ -showbHash :: Hash -> Builder -showbHash = showb . FromStringShow -{-# INLINE showbHash #-} - -$(deriveShow ''Mix) -$(deriveShow ''BoxLabel) -$(deriveShowPragmas defaultInlineShowb ''CondBox) -$(deriveShowPragmas defaultInlineShowbPrec ''Tix) -$(deriveShow ''TixModule) - -instance Show HpcPos where - showb = showbHpcPos - INLINE_INST_FUN(showb) - -instance Show Hash where - showb = showbHash - INLINE_INST_FUN(showb) +{-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Text.Show.Text.Trace.Hpc+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Monomorphic 'Show' functions for data types in the @hpc@ library.++/Since: 0.1/+-}+module Text.Show.Text.Trace.Hpc (+ showbMixPrec+ , showbBoxLabelPrec+ , showbCondBox+ , showbTixPrec+ , showbTixModulePrec+ , showbHpcPos+ , showbHash+ ) where++import Data.Monoid.Compat++import Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Builder, FromStringShow(..), singleton)+import Text.Show.Text.Data.Integral (showbIntPrec)+import Text.Show.Text.Data.Time ()+import Text.Show.Text.TH (deriveShow)++import Trace.Hpc.Mix (Mix, BoxLabel, CondBox)+import Trace.Hpc.Tix (Tix, TixModule)+import Trace.Hpc.Util (HpcPos, Hash, fromHpcPos)++#include "inline.h"++-- | Convert a 'Mix' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbMixPrec :: Int -> Mix -> Builder+showbMixPrec = showbPrec+{-# INLINE showbMixPrec #-}++-- | Convert a 'BoxLabel' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbBoxLabelPrec :: Int -> BoxLabel -> Builder+showbBoxLabelPrec = showbPrec+{-# INLINE showbBoxLabelPrec #-}++-- | Convert a 'CondBox' to a 'Builder'.+--+-- /Since: 0.1/+showbCondBox :: CondBox -> Builder+showbCondBox = showb+{-# INLINE showbCondBox #-}++-- | Convert a 'Tix' value to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbTixPrec :: Int -> Tix -> Builder+showbTixPrec = showbPrec+{-# INLINE showbTixPrec #-}++-- | Convert a 'TixModule' to a 'Builder' with the given precedence.+--+-- /Since: 0.1/+showbTixModulePrec :: Int -> TixModule -> Builder+showbTixModulePrec = showbPrec+{-# INLINE showbTixModulePrec #-}++-- | Convert a 'HpcPos' to a 'Builder'.+--+-- /Since: 0.1/+showbHpcPos :: HpcPos -> Builder+showbHpcPos hp = case fromHpcPos hp of+ (l1, c1, l2, c2) -> showbIntPrec 0 l1+ <> (singleton ':' <> showbIntPrec 0 c1)+ <> (singleton '-' <> showbIntPrec 0 l2)+ <> (singleton ':' <> showbIntPrec 0 c2)+{-# INLINE showbHpcPos #-}++-- | Convert a 'Hash' to a 'Builder'.+--+-- /Since: 0.1/+showbHash :: Hash -> Builder+showbHash = showb . FromStringShow+{-# INLINE showbHash #-}++$(deriveShow ''Mix)+$(deriveShow ''BoxLabel)+$(deriveShow ''CondBox)+$(deriveShow ''Tix)+$(deriveShow ''TixModule)++instance Show HpcPos where+ showb = showbHpcPos+ INLINE_INST_FUN(showb)++instance Show Hash where+ showb = showbHash+ INLINE_INST_FUN(showb)
src/Text/Show/Text/Utils.hs view
@@ -1,26 +1,31 @@-{-# LANGUAGE OverloadedStrings #-} -{-| -Module: Text.Show.Text.Utils -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Miscellaneous utility functions. --} -module Text.Show.Text.Utils where - -import Prelude hiding (Show) -import Text.Show.Text (Show, Builder, showbUnary, singleton) - --- | A shorter name for 'singleton' for convenience's sake (since it tends to be used --- pretty often in @text-show-instances@). -s :: Char -> Builder -s = singleton -{-# INLINE s #-} - --- | This pattern is used frequently when showing container types. -showbUnaryList :: Show a => Int -> [a] -> Builder -showbUnaryList p = showbUnary "fromList" p -{-# INLINE showbUnaryList #-} +{-# LANGUAGE OverloadedStrings #-}+{-|+Module: Text.Show.Text.Utils+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Miscellaneous utility functions.+-}+module Text.Show.Text.Utils (showbUnaryListWith, showbUnaryList) where++import Prelude hiding (Show)++import Text.Show.Text (Show(showbPrec), Builder, showbUnaryWith)+import Text.Show.Text.Data.List (showbListWith)++-- | This pattern is used frequently when showing container types.+showbUnaryListWith :: (a -> Builder) -> Int -> [a] -> Builder+showbUnaryListWith sp p = showbUnaryWith (const $ showbListWith sp) "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 :: Show a => Int -> [a] -> Builder+showbUnaryList p = showbUnaryWith showbPrec "fromList" p+{-# INLINE showbUnaryList #-}
tests/Instances/Compiler/Hoopl.hs view
@@ -1,72 +1,72 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Compiler.Hoopl -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @hoopl@ library. --} -module Instances.Compiler.Hoopl () where - -import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed(..), - UniqueMap, UniqueSet, C, mapFromList, setFromList) -#if MIN_VERSION_hoopl(3,9,0) -import Compiler.Hoopl.Internals (uniqueToLbl) -#else -import Compiler.Hoopl (Unique, intToUnique) -import Compiler.Hoopl.GHC (uniqueToLbl) -#endif -import Compiler.Hoopl.Passes.Dominator (DominatorNode(..), DominatorTree(..), DPath(..)) - -import Instances.Utils ((<@>)) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), oneof) - -instance Arbitrary Label where - arbitrary = uniqueToLbl <$> arbitrary - -instance Arbitrary v => Arbitrary (LabelMap v) where - arbitrary = mapFromList <$> arbitrary - -instance Arbitrary LabelSet where - arbitrary = setFromList <$> arbitrary - -instance Arbitrary a => Arbitrary (Pointed C C a) where - arbitrary = oneof [pure Bot, PElem <$> arbitrary, pure Top] - -#if !(MIN_VERSION_hoopl(3,9,0)) -instance Arbitrary Unique where - arbitrary = intToUnique <$> arbitrary -#endif - -instance Arbitrary v => Arbitrary (UniqueMap v) where - arbitrary = mapFromList <$> arbitrary - -instance Arbitrary UniqueSet where - arbitrary = setFromList <$> arbitrary - -instance Arbitrary DominatorNode where - arbitrary = oneof [pure Entry, Labelled <$> arbitrary] - -instance Arbitrary DominatorTree where - arbitrary = Dominates <$> arbitrary <@> [fDominatorTree] --- arbitrary = Dominates <$> arbitrary <*> arbitrary - -deriving instance Arbitrary DPath - -------------------------------------------------------------------------------- --- Workarounds to make Arbitrary instances faster -------------------------------------------------------------------------------- - -fDominatorTree :: DominatorTree -fDominatorTree = Dominates Entry [] +{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Compiler.Hoopl+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @hoopl@ library.+-}+module Instances.Compiler.Hoopl () where++import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed(..),+ UniqueMap, UniqueSet, C, mapFromList, setFromList)+#if MIN_VERSION_hoopl(3,9,0)+import Compiler.Hoopl.Internals (uniqueToLbl)+#else+import Compiler.Hoopl (Unique, intToUnique)+import Compiler.Hoopl.GHC (uniqueToLbl)+#endif+import Compiler.Hoopl.Passes.Dominator (DominatorNode(..), DominatorTree(..), DPath(..))++import Instances.Utils ((<@>))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), oneof)++instance Arbitrary Label where+ arbitrary = uniqueToLbl <$> arbitrary++instance Arbitrary v => Arbitrary (LabelMap v) where+ arbitrary = mapFromList <$> arbitrary++instance Arbitrary LabelSet where+ arbitrary = setFromList <$> arbitrary++instance Arbitrary a => Arbitrary (Pointed C C a) where+ arbitrary = oneof [pure Bot, PElem <$> arbitrary, pure Top]++#if !(MIN_VERSION_hoopl(3,9,0))+instance Arbitrary Unique where+ arbitrary = intToUnique <$> arbitrary+#endif++instance Arbitrary v => Arbitrary (UniqueMap v) where+ arbitrary = mapFromList <$> arbitrary++instance Arbitrary UniqueSet where+ arbitrary = setFromList <$> arbitrary++instance Arbitrary DominatorNode where+ arbitrary = oneof [pure Entry, Labelled <$> arbitrary]++instance Arbitrary DominatorTree where+ arbitrary = Dominates <$> arbitrary <@> [fDominatorTree]+-- arbitrary = Dominates <$> arbitrary <*> arbitrary++deriving instance Arbitrary DPath++-------------------------------------------------------------------------------+-- Workarounds to make Arbitrary instances faster+-------------------------------------------------------------------------------++fDominatorTree :: DominatorTree+fDominatorTree = Dominates Entry []
tests/Instances/Control/Applicative/Trans.hs view
@@ -1,28 +1,28 @@-{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Control.Applicative.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for applicative functor transformers. --} -module Instances.Control.Applicative.Trans () where - -import Control.Applicative.Backwards (Backwards(..)) -import Control.Applicative.Lift (Lift(..)) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), oneof) - -deriving instance Arbitrary (f a) => Arbitrary (Backwards f a) - -instance (Arbitrary a, Arbitrary (f a)) => Arbitrary (Lift f a) where - arbitrary = oneof [Pure <$> arbitrary, Other <$> arbitrary] +{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Control.Applicative.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for applicative functor transformers.+-}+module Instances.Control.Applicative.Trans () where++import Control.Applicative.Backwards (Backwards(..))+import Control.Applicative.Lift (Lift(..))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), oneof)++deriving instance Arbitrary (f a) => Arbitrary (Backwards f a)++instance (Arbitrary a, Arbitrary (f a)) => Arbitrary (Lift f a) where+ arbitrary = oneof [Pure <$> arbitrary, Other <$> arbitrary]
tests/Instances/Control/Monad/Trans.hs view
@@ -1,35 +1,35 @@-{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE UndecidableInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} -{-| -Module: Instances.Control.Monad.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for monad transformers. --} -module Instances.Control.Monad.Trans () where - -import Control.Monad.Trans.Error (ErrorT(..)) -import Control.Monad.Trans.Except (ExceptT(..)) -import Control.Monad.Trans.Identity (IdentityT(..)) -import Control.Monad.Trans.List (ListT(..)) -import Control.Monad.Trans.Maybe (MaybeT(..)) -import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT(..)) -import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT(..)) - -import Test.QuickCheck (Arbitrary) - -deriving instance Arbitrary (m (Either e a)) => Arbitrary (ErrorT e m a) -deriving instance Arbitrary (m (Either e a)) => Arbitrary (ExceptT e m a) -deriving instance Arbitrary (f a) => Arbitrary (IdentityT f a) -deriving instance Arbitrary (m [a]) => Arbitrary (ListT m a) -deriving instance Arbitrary (m (Maybe a)) => Arbitrary (MaybeT m a) -deriving instance Arbitrary (m (a, w)) => Arbitrary (WL.WriterT w m a) -deriving instance Arbitrary (m (a, w)) => Arbitrary (WS.WriterT w m a) +{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}+{-|+Module: Instances.Control.Monad.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for monad transformers.+-}+module Instances.Control.Monad.Trans () where++import Control.Monad.Trans.Error (ErrorT(..))+import Control.Monad.Trans.Except (ExceptT(..))+import Control.Monad.Trans.Identity (IdentityT(..))+import Control.Monad.Trans.List (ListT(..))+import Control.Monad.Trans.Maybe (MaybeT(..))+import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT(..))+import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT(..))++import Test.QuickCheck (Arbitrary)++deriving instance Arbitrary (m (Either e a)) => Arbitrary (ErrorT e m a)+deriving instance Arbitrary (m (Either e a)) => Arbitrary (ExceptT e m a)+deriving instance Arbitrary (f a) => Arbitrary (IdentityT f a)+deriving instance Arbitrary (m [a]) => Arbitrary (ListT m a)+deriving instance Arbitrary (m (Maybe a)) => Arbitrary (MaybeT m a)+deriving instance Arbitrary (m (a, w)) => Arbitrary (WL.WriterT w m a)+deriving instance Arbitrary (m (a, w)) => Arbitrary (WS.WriterT w m a)
+ tests/Instances/Data/Bifunctor.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module: Instances.Data.Bifunctor+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 data types in the @bifunctors@ library.+-}+module Instances.Data.Bifunctor () where++import Data.Bifunctor.Biff (Biff(..))+import Data.Bifunctor.Clown (Clown(..))+import Data.Bifunctor.Flip (Flip(..))+import Data.Bifunctor.Join (Join(..))+import Data.Bifunctor.Joker (Joker(..))+import Data.Bifunctor.Product (Product(..))+import Data.Bifunctor.Tannen (Tannen(..))+import Data.Bifunctor.Wrapped (WrappedBifunctor(..))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..))++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 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)+deriving instance Arbitrary (f (p a b)) => Arbitrary (Tannen f p a b)+deriving instance Arbitrary (p a b) => Arbitrary (WrappedBifunctor p a b)++instance (Arbitrary (f a b), Arbitrary (g a b)) => Arbitrary (Product f g a b) where+ arbitrary = Pair <$> arbitrary <*> arbitrary
tests/Instances/Data/Binary.hs view
@@ -1,27 +1,27 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Data.Binary -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for 'Decoder's. --} -module Instances.Data.Binary () where - -import Data.Binary.Get.Internal (Decoder(..)) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), oneof) -import Test.QuickCheck.Instances () - -instance Arbitrary a => Arbitrary (Decoder a) where - arbitrary = oneof [ Fail <$> arbitrary <*> arbitrary - , Partial <$> arbitrary - , Done <$> arbitrary <*> arbitrary - , BytesRead <$> arbitrary <*> arbitrary - ] +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Data.Binary+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 'Decoder's.+-}+module Instances.Data.Binary () where++import Data.Binary.Get.Internal (Decoder(..))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), oneof)+import Test.QuickCheck.Instances ()++instance Arbitrary a => Arbitrary (Decoder a) where+ arbitrary = oneof [ Fail <$> arbitrary <*> arbitrary+ , Partial <$> arbitrary+ , Done <$> arbitrary <*> arbitrary+ , BytesRead <$> arbitrary <*> arbitrary+ ]
tests/Instances/Data/Containers.hs view
@@ -1,26 +1,26 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Data.Containers -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types located in @containers@. --} -module Instances.Data.Containers () where - -import Data.Sequence (ViewL(..), ViewR(..)) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), oneof) -import Test.QuickCheck.Instances () - -instance Arbitrary a => Arbitrary (ViewL a) where - arbitrary = oneof [pure EmptyL, (:<) <$> arbitrary <*> arbitrary] - -instance Arbitrary a => Arbitrary (ViewR a) where - arbitrary = oneof [pure EmptyR, (:>) <$> arbitrary <*> arbitrary] +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Data.Containers+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types located in @containers@.+-}+module Instances.Data.Containers () where++import Data.Sequence (ViewL(..), ViewR(..))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), oneof)+import Test.QuickCheck.Instances ()++instance Arbitrary a => Arbitrary (ViewL a) where+ arbitrary = oneof [pure EmptyL, (:<) <$> arbitrary <*> arbitrary]++instance Arbitrary a => Arbitrary (ViewR a) where+ arbitrary = oneof [pure EmptyR, (:>) <$> arbitrary <*> arbitrary]
tests/Instances/Data/Functor/Trans.hs view
@@ -1,36 +1,36 @@-{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Data.Functor.Trans -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for functor transformers. --} -module Instances.Data.Functor.Trans () 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 Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), oneof) - -deriving instance Arbitrary (f (g a)) => Arbitrary (Compose f g a) -deriving instance Arbitrary a => Arbitrary (Constant a b) -deriving instance Arbitrary (f a) => Arbitrary (Reverse f a) - -instance (Arbitrary (f a), Arbitrary (g a)) => Arbitrary (Product f g a) where - arbitrary = Pair <$> arbitrary <*> arbitrary - -instance (Arbitrary (f a), Arbitrary (g a)) => Arbitrary (Sum f g a) where - arbitrary = oneof [InL <$> arbitrary, InR <$> arbitrary] +{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Data.Functor.Trans+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for functor transformers.+-}+module Instances.Data.Functor.Trans () 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 Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), oneof)++deriving instance Arbitrary (f (g a)) => Arbitrary (Compose f g a)+deriving instance Arbitrary a => Arbitrary (Constant a b)+deriving instance Arbitrary (f a) => Arbitrary (Reverse f a)++instance (Arbitrary (f a), Arbitrary (g a)) => Arbitrary (Product f g a) where+ arbitrary = Pair <$> arbitrary <*> arbitrary++instance (Arbitrary (f a), Arbitrary (g a)) => Arbitrary (Sum f g a) where+ arbitrary = oneof [InL <$> arbitrary, InR <$> arbitrary]
tests/Instances/Data/List/NonEmpty.hs view
@@ -1,22 +1,22 @@-{-# 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: Experimental -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 +{-# 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 view
@@ -1,32 +1,32 @@-{-# 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: Experimental -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 +{-# 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/Data/String/UTF8.hs
@@ -1,22 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Data.String.UTF8 -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for 'UTF8' strings. --} -module Instances.Data.String.UTF8 () where - -import Data.String.UTF8 (UTF8, fromRep) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..)) - -instance Arbitrary a => Arbitrary (UTF8 a) where - arbitrary = fromRep <$> arbitrary
tests/Instances/Data/Tagged.hs view
@@ -1,19 +1,19 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Data.Tagged -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for 'Tagged' values. --} -module Instances.Data.Tagged () where - -import Data.Tagged (Tagged(..)) -import Test.QuickCheck (Arbitrary) - -deriving instance Arbitrary b => Arbitrary (Tagged s b) +{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Data.Tagged+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 'Tagged' values.+-}+module Instances.Data.Tagged () where++import Data.Tagged (Tagged(..))+import Test.QuickCheck (Arbitrary)++deriving instance Arbitrary b => Arbitrary (Tagged s b)
tests/Instances/Language/Haskell/TH.hs view
@@ -1,620 +1,610 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeSynonymInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Language.Haskell.TH -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @template-haskell@ library. --} -module Instances.Language.Haskell.TH () where - -#if !(MIN_VERSION_template_haskell(2,10,0)) -import GHC.Exts (Int(I#)) -#endif - -import Instances.Utils ((<@>)) - -import Language.Haskell.TH.PprLib (Doc, text) -import Language.Haskell.TH.Syntax -#if !(MIN_VERSION_template_haskell(2,8,0)) -import Language.Haskell.TH.Syntax.Internals -#endif - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) - -instance Arbitrary Body where - arbitrary = oneof $ map pure [ GuardedB [(fGuard, fExp)] - , NormalB fExp - ] --- arbitrary = oneof [GuardedB <$> arbitrary, NormalB <$> arbitrary] - -deriving instance Bounded Callconv -deriving instance Enum Callconv -instance Arbitrary Callconv where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Clause where - arbitrary = pure $ Clause [fPat] fBody [fDec] --- 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 <*> arbitrary <*> arbitrary --- ] - -instance Arbitrary Dec where - arbitrary = oneof [ - FunD <$> arbitrary <@> [fClause] - , pure $ ValD fPat fBody [fDec] - , DataD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , NewtypeD [fPred] <$> arbitrary <*> arbitrary <*> 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 -#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 - , RoleAnnotD <$> arbitrary <*> arbitrary - , TySynInstD <$> arbitrary <*> arbitrary -#else - , TySynInstD <$> arbitrary <*> arbitrary <*> arbitrary -#endif -#if MIN_VERSION_template_haskell(2,10,0) - , StandaloneDerivD <$> arbitrary <*> arbitrary - , DefaultSigD <$> arbitrary <*> arbitrary -#endif - ] --- arbitrary = oneof [ --- FunD <$> arbitrary <*> arbitrary --- , ValD <$> arbitrary <*> arbitrary <*> arbitrary --- , DataD <$> arbitrary <*> arbitrary <*> arbitrary --- <*> arbitrary <*> arbitrary --- , NewtypeD <$> arbitrary <*> arbitrary <*> arbitrary --- <*> arbitrary <*> arbitrary --- , TySynD <$> arbitrary <*> arbitrary <*> arbitrary --- , ClassD <$> arbitrary <*> arbitrary <*> arbitrary --- <*> arbitrary <*> arbitrary --- , InstanceD <$> arbitrary <*> arbitrary <*> arbitrary --- , SigD <$> arbitrary <*> arbitrary --- , ForeignD <$> arbitrary --- , PragmaD <$> arbitrary --- , FamilyD <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary --- , DataInstD <$> arbitrary <*> arbitrary <*> arbitrary --- <*> arbitrary <*> arbitrary --- , NewtypeInstD <$> arbitrary <*> arbitrary <*> arbitrary --- <*> 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 --- , RoleAnnotD <$> arbitrary <*> arbitrary --- , TySynInstD <$> arbitrary <*> arbitrary --- #else --- , TySynInstD <$> arbitrary <*> arbitrary <*> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,10,0) --- , StandaloneDerivD <$> arbitrary <*> arbitrary --- , DefaultSigD <$> arbitrary <*> arbitrary --- #endif --- ] - -instance Arbitrary Exp where - arbitrary = oneof [ VarE <$> arbitrary - , ConE <$> arbitrary - , LitE <$> arbitrary - , pure $ AppE fExp fExp - , pure $ InfixE (Just fExp) fExp (Just fExp) - , pure $ LamE [fPat] fExp - , pure $ TupE [fExp] - , pure $ CondE fExp fExp fExp - , pure $ LetE [fDec] fExp - , pure $ CaseE fExp [fMatch] - , pure $ DoE [fStmt] - , pure $ CompE [fStmt] - , pure $ ArithSeqE fRange - , pure $ ListE [fExp] - , SigE fExp <$> arbitrary - , RecConE <$> arbitrary <@> [fFieldExp] - , pure $ RecUpdE fExp [fFieldExp] -#if MIN_VERSION_template_haskell(2,6,0) - , pure $ UnboxedTupE [fExp] -#endif -#if MIN_VERSION_template_haskell(2,7,0) - , pure $ UInfixE fExp fExp fExp - , pure $ ParensE fExp -#endif -#if MIN_VERSION_template_haskell(2,8,0) - , pure $ LamCaseE [fMatch] - , pure $ MultiIfE [(fGuard, fExp)] -#endif -#if MIN_VERSION_template_haskell(2,10,0) - , pure $ StaticE fExp -#endif - ] --- arbitrary = oneof [ VarE <$> arbitrary --- , ConE <$> arbitrary --- , LitE <$> arbitrary --- , AppE <$> arbitrary <*> arbitrary --- , InfixE <$> arbitrary <*> arbitrary <*> arbitrary --- , LamE <$> arbitrary <*> arbitrary --- , TupE <$> arbitrary --- , CondE <$> arbitrary <*> arbitrary <*> arbitrary --- , LetE <$> arbitrary <*> arbitrary --- , CaseE <$> arbitrary <*> arbitrary --- , DoE <$> arbitrary --- , CompE <$> arbitrary --- , ArithSeqE <$> arbitrary --- , ListE <$> arbitrary --- , SigE <$> arbitrary <*> arbitrary --- , RecConE <$> arbitrary <*> arbitrary --- , RecUpdE <$> arbitrary <*> arbitrary --- #if MIN_VERSION_template_haskell(2,6,0) --- , UnboxedTupE <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,7,0) --- , UInfixE <$> arbitrary <*> arbitrary <*> arbitrary --- , ParensE <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,8,0) --- , LamCaseE <$> arbitrary --- , MultiIfE <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,10,0) --- , StaticE <$> arbitrary --- #endif --- ] - -deriving instance Bounded FamFlavour -deriving instance Enum FamFlavour -instance Arbitrary FamFlavour where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Fixity where - arbitrary = Fixity <$> arbitrary <*> arbitrary - -deriving instance Bounded FixityDirection -deriving instance Enum FixityDirection -instance Arbitrary FixityDirection where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Foreign where - arbitrary = oneof [ ImportF <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary - , ExportF <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - ] - -instance Arbitrary FunDep where - arbitrary = FunDep <$> arbitrary <*> arbitrary - -instance Arbitrary Guard where - arbitrary = oneof $ map pure [ NormalG fExp - , PatG [fStmt] - ] --- arbitrary = oneof [NormalG <$> arbitrary, PatG <$> arbitrary] - -instance Arbitrary Info where - arbitrary = oneof [ -#if MIN_VERSION_template_haskell(2,7,0) - pure $ ClassI fDec [fDec] -#elif MIN_VERSION_template_haskell(2,5,0) - pure $ ClassI fDec [fClassInstance] -#else - pure $ ClassI fDec -#endif - , ClassOpI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , pure $ TyConI fDec - , PrimTyConI <$> arbitrary <*> arbitrary <*> arbitrary - , DataConI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , VarI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , TyVarI <$> arbitrary <*> arbitrary -#if MIN_VERSION_template_haskell(2,7,0) - , pure $ FamilyI fDec [fDec] -#endif - ] --- arbitrary = oneof [ --- #if MIN_VERSION_template_haskell(2,5,0) --- ClassI <$> arbitrary <*> arbitrary --- #else --- ClassI <$> arbitrary --- #endif --- , ClassOpI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary --- , TyConI <$> arbitrary --- , PrimTyConI <$> arbitrary <*> arbitrary <*> arbitrary --- , DataConI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary --- , VarI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary --- , TyVarI <$> arbitrary <*> arbitrary --- #if MIN_VERSION_template_haskell(2,7,0) --- , FamilyI <$> arbitrary <*> arbitrary --- #endif --- ] - -instance Arbitrary Lit where - arbitrary = oneof [ CharL <$> arbitrary - , StringL <$> arbitrary - , IntegerL <$> arbitrary - , RationalL <$> arbitrary - , IntPrimL <$> arbitrary - , WordPrimL <$> arbitrary - , FloatPrimL <$> arbitrary - , DoublePrimL <$> arbitrary -#if MIN_VERSION_template_haskell(2,5,0) - , StringPrimL <$> arbitrary -#endif - ] - -instance Arbitrary Loc where - arbitrary = Loc <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary - -#if !(MIN_VERSION_template_haskell(2,10,0)) -deriving instance Show Loc -#endif - -instance Arbitrary Match where - arbitrary = Match <$> arbitrary <@> fBody <@> [fDec] --- arbitrary = Match <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary Name where - arbitrary = Name <$> arbitrary <*> arbitrary - -instance Arbitrary NameFlavour where - arbitrary = oneof [ pure NameS - , NameQ <$> arbitrary -#if MIN_VERSION_template_haskell(2,10,0) - , NameU <$> arbitrary - , NameL <$> arbitrary -#else - , (\(I# i#) -> NameU i#) <$> arbitrary - , (\(I# i#) -> NameL i#) <$> arbitrary -#endif - , NameG <$> arbitrary <*> arbitrary <*> arbitrary - ] - -deriving instance Bounded NameIs -deriving instance Enum NameIs -deriving instance Show NameIs -instance Arbitrary NameIs where - arbitrary = arbitraryBoundedEnum - -deriving instance Bounded NameSpace -deriving instance Enum NameSpace -instance Arbitrary NameSpace where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Pat where - arbitrary = oneof [ LitP <$> arbitrary - , VarP <$> arbitrary - , pure $ TupP [fPat] - , ConP <$> arbitrary <@> [fPat] - , InfixP fPat <$> arbitrary <@> fPat - , pure $ TildeP fPat - , pure $ BangP fPat - , AsP <$> arbitrary <@> fPat - , pure WildP - , RecP <$> arbitrary <@> [fFieldPat] - , pure $ ListP [fPat] - , SigP fPat <$> arbitrary -#if MIN_VERSION_template_haskell(2,5,0) - , pure $ ViewP fExp fPat -#endif -#if MIN_VERSION_template_haskell(2,6,0) - , pure $ UnboxedTupP [fPat] -#endif -#if MIN_VERSION_template_haskell(2,7,0) - , UInfixP fPat <$> arbitrary <@> fPat - , pure $ ParensP fPat -#endif - ] --- arbitrary = oneof [ LitP <$> arbitrary --- , VarP <$> arbitrary --- , TupP <$> arbitrary --- , ConP <$> arbitrary <*> arbitrary --- , InfixP <$> arbitrary <*> arbitrary <*> arbitrary --- , TildeP <$> arbitrary --- , BangP <$> arbitrary --- , AsP <$> arbitrary <*> arbitrary --- , pure WildP --- , RecP <$> arbitrary <*> arbitrary --- , ListP <$> arbitrary --- , SigP <$> arbitrary <*> arbitrary --- #if MIN_VERSION_template_haskell(2,5,0) --- , ViewP <$> arbitrary <*> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,6,0) --- , UnboxedTupP <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,7,0) --- , UInfixP <$> arbitrary <*> arbitrary <*> arbitrary --- , ParensP <$> arbitrary --- #endif --- ] - -instance Arbitrary Pragma where - arbitrary = oneof - [ -#if MIN_VERSION_template_haskell(2,8,0) - InlineP <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , SpecialiseP <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - , SpecialiseInstP <$> arbitrary - , RuleP <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary -# if MIN_VERSION_template_haskell(2,9,0) - , AnnP <$> arbitrary <*> arbitrary -# endif -# if MIN_VERSION_template_haskell(2,10,0) - , LineP <$> arbitrary <*> arbitrary -# endif -#else - InlineP <$> arbitrary <*> arbitrary - , SpecialiseP <$> arbitrary <*> arbitrary <*> arbitrary -#endif - ] - -instance Arbitrary Range where - arbitrary = oneof $ map pure [ FromR fExp - , FromThenR fExp fExp - , FromToR fExp fExp - , FromThenToR fExp fExp fExp - ] --- arbitrary = oneof [ FromR <$> arbitrary --- , FromThenR <$> arbitrary <*> arbitrary --- , FromToR <$> arbitrary <*> arbitrary --- , FromThenToR <$> arbitrary <*> arbitrary <*> arbitrary --- ] - -deriving instance Bounded Safety -deriving instance Enum Safety -instance Arbitrary Safety where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Stmt where - arbitrary = oneof $ map pure [ BindS fPat fExp - , LetS [fDec] - , NoBindS fExp - , ParS [[fStmt]] - ] --- arbitrary = oneof [ BindS <$> arbitrary <*> arbitrary --- , LetS <$> arbitrary --- , NoBindS <$> arbitrary --- , 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 - , ConT <$> arbitrary - , TupleT <$> arbitrary - , pure ArrowT - , pure ListT - , pure $ AppT fType fType - , pure $ SigT fType fKind -#if MIN_VERSION_template_haskell(2,6,0) - , UnboxedTupleT <$> arbitrary -#endif -#if MIN_VERSION_template_haskell(2,8,0) - , PromotedT <$> arbitrary - , PromotedTupleT <$> arbitrary - , pure PromotedNilT - , pure PromotedConsT - , pure StarT - , pure ConstraintT - , LitT <$> arbitrary -#endif -#if MIN_VERSION_template_haskell(2,10,0) - , pure EqualityT -#endif - ] --- arbitrary = oneof [ ForallT <$> arbitrary <*> arbitrary <*> arbitrary --- , VarT <$> arbitrary --- , ConT <$> arbitrary --- , TupleT <$> arbitrary --- , pure ArrowT --- , pure ListT --- , AppT <$> arbitrary <*> arbitrary --- , SigT <$> arbitrary <*> arbitrary --- #if MIN_VERSION_template_haskell(2,6,0) --- , UnboxedTupleT <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,7,0) --- , PromotedT <$> arbitrary --- , PromotedTupleT <$> arbitrary --- , pure PromotedNilT --- , pure PromotedConsT --- , pure StarT --- , pure ConstraintT --- , LitT <$> arbitrary --- #endif --- #if MIN_VERSION_template_haskell(2,10,0) --- , pure EqualityT --- #endif --- ] - -instance Arbitrary TyVarBndr where - arbitrary = oneof [PlainTV <$> arbitrary, KindedTV <$> arbitrary <@> fKind] --- arbitrary = oneof [PlainTV <$> arbitrary, KindedTV <$> arbitrary <*> arbitrary] - -#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0)) -instance Arbitrary ClassInstance where - arbitrary = ClassInstance <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary -#endif - -#if MIN_VERSION_template_haskell(2,8,0) -deriving instance Bounded Inline -deriving instance Enum Inline -instance Arbitrary Inline where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Phases where - arbitrary = oneof [ pure AllPhases - , FromPhase <$> arbitrary - , BeforePhase <$> arbitrary - ] - -instance Arbitrary RuleBndr where - arbitrary = oneof [RuleVar <$> arbitrary, TypedRuleVar <$> arbitrary <*> arbitrary] - -deriving instance Bounded RuleMatch -deriving instance Enum RuleMatch -instance Arbitrary RuleMatch where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary TyLit where - arbitrary = oneof [NumTyLit <$> arbitrary, StrTyLit <$> arbitrary] -#else -instance Arbitrary InlineSpec where - arbitrary = InlineSpec <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary Kind where - arbitrary = oneof [pure StarK, pure $ ArrowK fKind fKind] --- arbitrary = oneof [pure StarK, ArrowK <$> arbitrary <*> arbitrary] -#endif - -#if MIN_VERSION_template_haskell(2,9,0) -instance Arbitrary AnnLookup where - arbitrary = oneof [AnnLookupModule <$> arbitrary, AnnLookupName <$> arbitrary] - -instance Arbitrary AnnTarget where - arbitrary = oneof [ pure ModuleAnnotation - , TypeAnnotation <$> arbitrary - , ValueAnnotation <$> arbitrary - ] - -instance Arbitrary Module where - arbitrary = Module <$> arbitrary <*> arbitrary - -instance Arbitrary ModuleInfo where - arbitrary = ModuleInfo <$> arbitrary - -deriving instance Bounded Role -deriving instance Enum Role -instance Arbitrary Role where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary TySynEqn where - arbitrary = TySynEqn <$> arbitrary <*> arbitrary -#endif - -instance Arbitrary Doc where - arbitrary = text <$> arbitrary - -#if !(MIN_VERSION_template_haskell(2,10,0)) -instance Arbitrary Pred where - arbitrary = oneof [ ClassP <$> arbitrary <@> [fType] - , pure $ EqualP fType fType - ] --- arbitrary = oneof [ ClassP <$> arbitrary <*> arbitrary --- , EqualP <$> arbitrary <*> arbitrary --- ] -#endif - -deriving instance Arbitrary ModName -deriving instance Arbitrary OccName -deriving instance Arbitrary PkgName - -#if !(MIN_VERSION_template_haskell(2,9,0)) -deriving instance Show ModName -deriving instance Show OccName -deriving instance Show PkgName -#endif - -------------------------------------------------------------------------------- --- Workarounds to make Arbitrary instances faster -------------------------------------------------------------------------------- - -fBody :: Body -fBody = GuardedB [] - -#if MIN_VERSION_template_haskell(2,5,0) && !MIN_VERSION_template_haskell(2,7,0) -fClassInstance :: ClassInstance -fClassInstance = ClassInstance fName [fTyVarBndr] [fPred] fName [fType] -#endif - -fClause :: Clause -fClause = Clause [] fBody [] - -fCon :: Con -fCon = NormalC fName [] - -fDec :: Dec -fDec = FunD fName [] - -fExp :: Exp -fExp = TupE [] - -fFieldExp :: FieldExp -fFieldExp = (fName, fExp) - -fFieldPat :: FieldPat -fFieldPat = (fName, fPat) - -fGuard :: Guard -fGuard = PatG [] - -fKind :: Kind -#if MIN_VERSION_template_haskell(2,8,0) -fKind = fType -#else -fKind = StarK -#endif - -fMatch :: Match -fMatch = Match fPat fBody [] - -fName :: Name -fName = Name (OccName "") NameS - -fPat :: Pat -fPat = WildP - -fPred :: Pred -#if MIN_VERSION_template_haskell(2,10,0) -fPred = fType -#else -fPred = ClassP fName [] -#endif - -fRange :: Range -fRange = FromR fExp - -fStmt :: Stmt -fStmt = LetS [] - -fType :: Type -fType = ListT - -fTyVarBndr :: TyVarBndr -fTyVarBndr = PlainTV fName +{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Language.Haskell.TH+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @template-haskell@ library.+-}+module Instances.Language.Haskell.TH () where++#if !(MIN_VERSION_template_haskell(2,10,0))+import GHC.Exts (Int(I#))+#endif++import Instances.Utils ((<@>))++import Language.Haskell.TH.PprLib (Doc, text)+import Language.Haskell.TH.Syntax+#if !(MIN_VERSION_template_haskell(2,8,0))+import Language.Haskell.TH.Syntax.Internals+#endif++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)++instance Arbitrary Body where+ arbitrary = oneof $ map pure [ GuardedB [(fGuard, fExp)]+ , NormalB fExp+ ]+-- arbitrary = oneof [GuardedB <$> arbitrary, NormalB <$> arbitrary]++deriving instance Bounded Callconv+deriving instance Enum Callconv+instance Arbitrary Callconv where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Clause where+ arbitrary = pure $ Clause [fPat] fBody [fDec]+-- 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 <*> arbitrary <*> arbitrary+-- ]++instance Arbitrary Dec where+ arbitrary = oneof [+ FunD <$> arbitrary <@> [fClause]+ , pure $ ValD fPat fBody [fDec]+ , DataD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , NewtypeD [fPred] <$> arbitrary <*> arbitrary <*> 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+#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+ , RoleAnnotD <$> arbitrary <*> arbitrary+ , TySynInstD <$> arbitrary <*> arbitrary+#else+ , TySynInstD <$> arbitrary <*> arbitrary <*> arbitrary+#endif+#if MIN_VERSION_template_haskell(2,10,0)+ , StandaloneDerivD <$> arbitrary <*> arbitrary+ , DefaultSigD <$> arbitrary <*> arbitrary+#endif+ ]+-- arbitrary = oneof [+-- FunD <$> arbitrary <*> arbitrary+-- , ValD <$> arbitrary <*> arbitrary <*> arbitrary+-- , DataD <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> arbitrary <*> arbitrary+-- , NewtypeD <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> arbitrary <*> arbitrary+-- , TySynD <$> arbitrary <*> arbitrary <*> arbitrary+-- , ClassD <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> arbitrary <*> arbitrary+-- , InstanceD <$> arbitrary <*> arbitrary <*> arbitrary+-- , SigD <$> arbitrary <*> arbitrary+-- , ForeignD <$> arbitrary+-- , PragmaD <$> arbitrary+-- , FamilyD <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+-- , DataInstD <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> arbitrary <*> arbitrary+-- , NewtypeInstD <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> 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+-- , RoleAnnotD <$> arbitrary <*> arbitrary+-- , TySynInstD <$> arbitrary <*> arbitrary+-- #else+-- , TySynInstD <$> arbitrary <*> arbitrary <*> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,10,0)+-- , StandaloneDerivD <$> arbitrary <*> arbitrary+-- , DefaultSigD <$> arbitrary <*> arbitrary+-- #endif+-- ]++instance Arbitrary Exp where+ arbitrary = oneof [ VarE <$> arbitrary+ , ConE <$> arbitrary+ , LitE <$> arbitrary+ , pure $ AppE fExp fExp+ , pure $ InfixE (Just fExp) fExp (Just fExp)+ , pure $ LamE [fPat] fExp+ , pure $ TupE [fExp]+ , pure $ CondE fExp fExp fExp+ , pure $ LetE [fDec] fExp+ , pure $ CaseE fExp [fMatch]+ , pure $ DoE [fStmt]+ , pure $ CompE [fStmt]+ , pure $ ArithSeqE fRange+ , pure $ ListE [fExp]+ , SigE fExp <$> arbitrary+ , RecConE <$> arbitrary <@> [fFieldExp]+ , pure $ RecUpdE fExp [fFieldExp]+#if MIN_VERSION_template_haskell(2,6,0)+ , pure $ UnboxedTupE [fExp]+#endif+#if MIN_VERSION_template_haskell(2,7,0)+ , pure $ UInfixE fExp fExp fExp+ , pure $ ParensE fExp+#endif+#if MIN_VERSION_template_haskell(2,8,0)+ , pure $ LamCaseE [fMatch]+ , pure $ MultiIfE [(fGuard, fExp)]+#endif+#if MIN_VERSION_template_haskell(2,10,0)+ , pure $ StaticE fExp+#endif+ ]+-- arbitrary = oneof [ VarE <$> arbitrary+-- , ConE <$> arbitrary+-- , LitE <$> arbitrary+-- , AppE <$> arbitrary <*> arbitrary+-- , InfixE <$> arbitrary <*> arbitrary <*> arbitrary+-- , LamE <$> arbitrary <*> arbitrary+-- , TupE <$> arbitrary+-- , CondE <$> arbitrary <*> arbitrary <*> arbitrary+-- , LetE <$> arbitrary <*> arbitrary+-- , CaseE <$> arbitrary <*> arbitrary+-- , DoE <$> arbitrary+-- , CompE <$> arbitrary+-- , ArithSeqE <$> arbitrary+-- , ListE <$> arbitrary+-- , SigE <$> arbitrary <*> arbitrary+-- , RecConE <$> arbitrary <*> arbitrary+-- , RecUpdE <$> arbitrary <*> arbitrary+-- #if MIN_VERSION_template_haskell(2,6,0)+-- , UnboxedTupE <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,7,0)+-- , UInfixE <$> arbitrary <*> arbitrary <*> arbitrary+-- , ParensE <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,8,0)+-- , LamCaseE <$> arbitrary+-- , MultiIfE <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,10,0)+-- , StaticE <$> arbitrary+-- #endif+-- ]++deriving instance Bounded FamFlavour+deriving instance Enum FamFlavour+instance Arbitrary FamFlavour where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Fixity where+ arbitrary = Fixity <$> arbitrary <*> arbitrary++deriving instance Bounded FixityDirection+deriving instance Enum FixityDirection+instance Arbitrary FixityDirection where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Foreign where+ arbitrary = oneof [ ImportF <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary+ , ExportF <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ ]++instance Arbitrary FunDep where+ arbitrary = FunDep <$> arbitrary <*> arbitrary++instance Arbitrary Guard where+ arbitrary = oneof $ map pure [ NormalG fExp+ , PatG [fStmt]+ ]+-- arbitrary = oneof [NormalG <$> arbitrary, PatG <$> arbitrary]++instance Arbitrary Info where+ arbitrary = oneof [+#if MIN_VERSION_template_haskell(2,7,0)+ pure $ ClassI fDec [fDec]+#elif MIN_VERSION_template_haskell(2,5,0)+ pure $ ClassI fDec [fClassInstance]+#else+ pure $ ClassI fDec+#endif+ , ClassOpI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , pure $ TyConI fDec+ , PrimTyConI <$> arbitrary <*> arbitrary <*> arbitrary+ , DataConI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , VarI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , TyVarI <$> arbitrary <*> arbitrary+#if MIN_VERSION_template_haskell(2,7,0)+ , pure $ FamilyI fDec [fDec]+#endif+ ]+-- arbitrary = oneof [+-- #if MIN_VERSION_template_haskell(2,5,0)+-- ClassI <$> arbitrary <*> arbitrary+-- #else+-- ClassI <$> arbitrary+-- #endif+-- , ClassOpI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+-- , TyConI <$> arbitrary+-- , PrimTyConI <$> arbitrary <*> arbitrary <*> arbitrary+-- , DataConI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+-- , VarI <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+-- , TyVarI <$> arbitrary <*> arbitrary+-- #if MIN_VERSION_template_haskell(2,7,0)+-- , FamilyI <$> arbitrary <*> arbitrary+-- #endif+-- ]++instance Arbitrary Lit where+ arbitrary = oneof [ CharL <$> arbitrary+ , StringL <$> arbitrary+ , IntegerL <$> arbitrary+ , RationalL <$> arbitrary+ , IntPrimL <$> arbitrary+ , WordPrimL <$> arbitrary+ , FloatPrimL <$> arbitrary+ , DoublePrimL <$> arbitrary+#if MIN_VERSION_template_haskell(2,5,0)+ , StringPrimL <$> arbitrary+#endif+ ]++instance Arbitrary Loc where+ arbitrary = Loc <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary++instance Arbitrary Match where+ arbitrary = Match <$> arbitrary <@> fBody <@> [fDec]+-- arbitrary = Match <$> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary Name where+ arbitrary = Name <$> arbitrary <*> arbitrary++instance Arbitrary NameFlavour where+ arbitrary = oneof [ pure NameS+ , NameQ <$> arbitrary+#if MIN_VERSION_template_haskell(2,10,0)+ , NameU <$> arbitrary+ , NameL <$> arbitrary+#else+ , (\(I# i#) -> NameU i#) <$> arbitrary+ , (\(I# i#) -> NameL i#) <$> arbitrary+#endif+ , NameG <$> arbitrary <*> arbitrary <*> arbitrary+ ]++deriving instance Bounded NameIs+deriving instance Enum NameIs+deriving instance Show NameIs+instance Arbitrary NameIs where+ arbitrary = arbitraryBoundedEnum++deriving instance Bounded NameSpace+deriving instance Enum NameSpace+instance Arbitrary NameSpace where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Pat where+ arbitrary = oneof [ LitP <$> arbitrary+ , VarP <$> arbitrary+ , pure $ TupP [fPat]+ , ConP <$> arbitrary <@> [fPat]+ , InfixP fPat <$> arbitrary <@> fPat+ , pure $ TildeP fPat+ , pure $ BangP fPat+ , AsP <$> arbitrary <@> fPat+ , pure WildP+ , RecP <$> arbitrary <@> [fFieldPat]+ , pure $ ListP [fPat]+ , SigP fPat <$> arbitrary+#if MIN_VERSION_template_haskell(2,5,0)+ , pure $ ViewP fExp fPat+#endif+#if MIN_VERSION_template_haskell(2,6,0)+ , pure $ UnboxedTupP [fPat]+#endif+#if MIN_VERSION_template_haskell(2,7,0)+ , UInfixP fPat <$> arbitrary <@> fPat+ , pure $ ParensP fPat+#endif+ ]+-- arbitrary = oneof [ LitP <$> arbitrary+-- , VarP <$> arbitrary+-- , TupP <$> arbitrary+-- , ConP <$> arbitrary <*> arbitrary+-- , InfixP <$> arbitrary <*> arbitrary <*> arbitrary+-- , TildeP <$> arbitrary+-- , BangP <$> arbitrary+-- , AsP <$> arbitrary <*> arbitrary+-- , pure WildP+-- , RecP <$> arbitrary <*> arbitrary+-- , ListP <$> arbitrary+-- , SigP <$> arbitrary <*> arbitrary+-- #if MIN_VERSION_template_haskell(2,5,0)+-- , ViewP <$> arbitrary <*> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,6,0)+-- , UnboxedTupP <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,7,0)+-- , UInfixP <$> arbitrary <*> arbitrary <*> arbitrary+-- , ParensP <$> arbitrary+-- #endif+-- ]++instance Arbitrary Pragma where+ arbitrary = oneof+ [+#if MIN_VERSION_template_haskell(2,8,0)+ InlineP <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , SpecialiseP <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ , SpecialiseInstP <$> arbitrary+ , RuleP <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary+# if MIN_VERSION_template_haskell(2,9,0)+ , AnnP <$> arbitrary <*> arbitrary+# endif+# if MIN_VERSION_template_haskell(2,10,0)+ , LineP <$> arbitrary <*> arbitrary+# endif+#else+ InlineP <$> arbitrary <*> arbitrary+ , SpecialiseP <$> arbitrary <*> arbitrary <*> arbitrary+#endif+ ]++instance Arbitrary Range where+ arbitrary = oneof $ map pure [ FromR fExp+ , FromThenR fExp fExp+ , FromToR fExp fExp+ , FromThenToR fExp fExp fExp+ ]+-- arbitrary = oneof [ FromR <$> arbitrary+-- , FromThenR <$> arbitrary <*> arbitrary+-- , FromToR <$> arbitrary <*> arbitrary+-- , FromThenToR <$> arbitrary <*> arbitrary <*> arbitrary+-- ]++deriving instance Bounded Safety+deriving instance Enum Safety+instance Arbitrary Safety where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Stmt where+ arbitrary = oneof $ map pure [ BindS fPat fExp+ , LetS [fDec]+ , NoBindS fExp+ , ParS [[fStmt]]+ ]+-- arbitrary = oneof [ BindS <$> arbitrary <*> arbitrary+-- , LetS <$> arbitrary+-- , NoBindS <$> arbitrary+-- , 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+ , ConT <$> arbitrary+ , TupleT <$> arbitrary+ , pure ArrowT+ , pure ListT+ , pure $ AppT fType fType+ , pure $ SigT fType fKind+#if MIN_VERSION_template_haskell(2,6,0)+ , UnboxedTupleT <$> arbitrary+#endif+#if MIN_VERSION_template_haskell(2,8,0)+ , PromotedT <$> arbitrary+ , PromotedTupleT <$> arbitrary+ , pure PromotedNilT+ , pure PromotedConsT+ , pure StarT+ , pure ConstraintT+ , LitT <$> arbitrary+#endif+#if MIN_VERSION_template_haskell(2,10,0)+ , pure EqualityT+#endif+ ]+-- arbitrary = oneof [ ForallT <$> arbitrary <*> arbitrary <*> arbitrary+-- , VarT <$> arbitrary+-- , ConT <$> arbitrary+-- , TupleT <$> arbitrary+-- , pure ArrowT+-- , pure ListT+-- , AppT <$> arbitrary <*> arbitrary+-- , SigT <$> arbitrary <*> arbitrary+-- #if MIN_VERSION_template_haskell(2,6,0)+-- , UnboxedTupleT <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,7,0)+-- , PromotedT <$> arbitrary+-- , PromotedTupleT <$> arbitrary+-- , pure PromotedNilT+-- , pure PromotedConsT+-- , pure StarT+-- , pure ConstraintT+-- , LitT <$> arbitrary+-- #endif+-- #if MIN_VERSION_template_haskell(2,10,0)+-- , pure EqualityT+-- #endif+-- ]++instance Arbitrary TyVarBndr where+ arbitrary = oneof [PlainTV <$> arbitrary, KindedTV <$> arbitrary <@> fKind]+-- arbitrary = oneof [PlainTV <$> arbitrary, KindedTV <$> arbitrary <*> arbitrary]++#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))+instance Arbitrary ClassInstance where+ arbitrary = ClassInstance <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary+#endif++#if MIN_VERSION_template_haskell(2,8,0)+deriving instance Bounded Inline+deriving instance Enum Inline+instance Arbitrary Inline where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Phases where+ arbitrary = oneof [ pure AllPhases+ , FromPhase <$> arbitrary+ , BeforePhase <$> arbitrary+ ]++instance Arbitrary RuleBndr where+ arbitrary = oneof [RuleVar <$> arbitrary, TypedRuleVar <$> arbitrary <*> arbitrary]++deriving instance Bounded RuleMatch+deriving instance Enum RuleMatch+instance Arbitrary RuleMatch where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary TyLit where+ arbitrary = oneof [NumTyLit <$> arbitrary, StrTyLit <$> arbitrary]+#else+instance Arbitrary InlineSpec where+ arbitrary = InlineSpec <$> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary Kind where+ arbitrary = oneof [pure StarK, pure $ ArrowK fKind fKind]+-- arbitrary = oneof [pure StarK, ArrowK <$> arbitrary <*> arbitrary]+#endif++#if MIN_VERSION_template_haskell(2,9,0)+instance Arbitrary AnnLookup where+ arbitrary = oneof [AnnLookupModule <$> arbitrary, AnnLookupName <$> arbitrary]++instance Arbitrary AnnTarget where+ arbitrary = oneof [ pure ModuleAnnotation+ , TypeAnnotation <$> arbitrary+ , ValueAnnotation <$> arbitrary+ ]++instance Arbitrary Module where+ arbitrary = Module <$> arbitrary <*> arbitrary+ +instance Arbitrary ModuleInfo where+ arbitrary = ModuleInfo <$> arbitrary++deriving instance Bounded Role+deriving instance Enum Role+instance Arbitrary Role where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary TySynEqn where+ arbitrary = TySynEqn <$> arbitrary <*> arbitrary+#endif++instance Arbitrary Doc where+ arbitrary = text <$> arbitrary++#if !(MIN_VERSION_template_haskell(2,10,0))+instance Arbitrary Pred where+ arbitrary = oneof [ ClassP <$> arbitrary <@> [fType]+ , pure $ EqualP fType fType+ ]+-- arbitrary = oneof [ ClassP <$> arbitrary <*> arbitrary+-- , EqualP <$> arbitrary <*> arbitrary+-- ]+#endif++deriving instance Arbitrary ModName+deriving instance Arbitrary OccName+deriving instance Arbitrary PkgName++-------------------------------------------------------------------------------+-- Workarounds to make Arbitrary instances faster+-------------------------------------------------------------------------------++fBody :: Body+fBody = GuardedB []++#if MIN_VERSION_template_haskell(2,5,0) && !MIN_VERSION_template_haskell(2,7,0)+fClassInstance :: ClassInstance+fClassInstance = ClassInstance fName [fTyVarBndr] [fPred] fName [fType]+#endif++fClause :: Clause+fClause = Clause [] fBody []++fCon :: Con+fCon = NormalC fName []++fDec :: Dec+fDec = FunD fName []++fExp :: Exp+fExp = TupE []++fFieldExp :: FieldExp+fFieldExp = (fName, fExp)++fFieldPat :: FieldPat+fFieldPat = (fName, fPat)++fGuard :: Guard+fGuard = PatG []++fKind :: Kind+#if MIN_VERSION_template_haskell(2,8,0)+fKind = fType+#else+fKind = StarK+#endif++fMatch :: Match+fMatch = Match fPat fBody []++fName :: Name+fName = Name (OccName "") NameS++fPat :: Pat+fPat = WildP++fPred :: Pred+#if MIN_VERSION_template_haskell(2,10,0)+fPred = fType+#else+fPred = ClassP fName []+#endif++fRange :: Range+fRange = FromR fExp++fStmt :: Stmt+fStmt = LetS []++fType :: Type+fType = ListT++fTyVarBndr :: TyVarBndr+fTyVarBndr = PlainTV fName
tests/Instances/Miscellaneous.hs view
@@ -1,90 +1,90 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Miscellaneous -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides miscellaneous 'Arbitrary' instances (taken from @text-show@). --} -module Instances.Miscellaneous () where - -#include "HsBaseConfig.h" - -import Data.Version (Version(..)) - -import Foreign.Ptr (Ptr, nullPtr, plusPtr) - -import Prelude () -import Prelude.Compat - -import System.Exit (ExitCode(..)) - -import Test.QuickCheck (Arbitrary(..), oneof) - -#if MIN_VERSION_base(4,5,0) - -import Foreign.C.Types (CInt(..)) -# if defined(HTYPE_GID_T) -import System.Posix.Types (CGid(..)) -# endif -# if defined(HTYPE_UID_T) -import System.Posix.Types (CUid(..)) -# endif - -#else - -import Foreign.C.Types (CInt) -# if defined(HTYPE_GID_T) -import System.Posix.Types (CGid) -# endif -# if defined(HTYPE_UID_T) -import System.Posix.Types (CUid) -# endif -import Test.QuickCheck (arbitrarySizedBoundedIntegral) - -#endif - -instance Arbitrary ExitCode where - arbitrary = oneof [pure ExitSuccess, ExitFailure <$> arbitrary] - -instance Arbitrary (Ptr a) where - arbitrary = plusPtr nullPtr <$> arbitrary - -instance Arbitrary Version where - arbitrary = pure $ Version [0] [""] --- arbitrary = Version <$> arbitrary <*> arbitrary - -#if MIN_VERSION_base(4,5,0) - -deriving instance Arbitrary CInt - -# if defined(HTYPE_GID_T) -deriving instance Arbitrary CGid -# endif - -# if defined(HTYPE_UID_T) -deriving instance Arbitrary CUid -# endif - -#else - -instance Arbitrary CInt where - arbitrary = arbitrarySizedBoundedIntegral - -# if defined(HTYPE_GID_T) -instance Arbitrary CGid where - arbitrary = arbitrarySizedBoundedIntegral -# endif - -# if defined(HTYPE_UID_T) -instance Arbitrary CUid where - arbitrary = arbitrarySizedBoundedIntegral -# endif - +{-# LANGUAGE CPP #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Miscellaneous+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides miscellaneous 'Arbitrary' instances (taken from @text-show@).+-}+module Instances.Miscellaneous () where++#include "HsBaseConfig.h"++import Data.Version (Version(..))++import Foreign.Ptr (Ptr, nullPtr, plusPtr)++import Prelude ()+import Prelude.Compat++import System.Exit (ExitCode(..))++import Test.QuickCheck (Arbitrary(..), oneof)++#if MIN_VERSION_base(4,5,0)++import Foreign.C.Types (CInt(..))+# if defined(HTYPE_GID_T)+import System.Posix.Types (CGid(..))+# endif+# if defined(HTYPE_UID_T)+import System.Posix.Types (CUid(..))+# endif++#else++import Foreign.C.Types (CInt)+# if defined(HTYPE_GID_T)+import System.Posix.Types (CGid)+# endif+# if defined(HTYPE_UID_T)+import System.Posix.Types (CUid)+# endif+import Test.QuickCheck (arbitrarySizedBoundedIntegral)++#endif++instance Arbitrary ExitCode where+ arbitrary = oneof [pure ExitSuccess, ExitFailure <$> arbitrary]++instance Arbitrary (Ptr a) where+ arbitrary = plusPtr nullPtr <$> arbitrary++instance Arbitrary Version where+ arbitrary = pure $ Version [0] [""]+-- arbitrary = Version <$> arbitrary <*> arbitrary++#if MIN_VERSION_base(4,5,0)++deriving instance Arbitrary CInt++# if defined(HTYPE_GID_T)+deriving instance Arbitrary CGid+# endif++# if defined(HTYPE_UID_T)+deriving instance Arbitrary CUid+# endif++#else++instance Arbitrary CInt where+ arbitrary = arbitrarySizedBoundedIntegral++# if defined(HTYPE_GID_T)+instance Arbitrary CGid where+ arbitrary = arbitrarySizedBoundedIntegral+# endif++# if defined(HTYPE_UID_T)+instance Arbitrary CUid where+ arbitrary = arbitrarySizedBoundedIntegral+# endif+ #endif
tests/Instances/System/Console/Haskeline.hs view
@@ -1,34 +1,34 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.System.Console.Haskeline -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @haskeline@ library. --} -module Instances.System.Console.Haskeline () where - -import Instances.Utils ((<@>)) - -import Prelude () -import Prelude.Compat - -import System.Console.Haskeline (Interrupt(..)) -import System.Console.Haskeline.Completion (Completion(..)) -import System.Console.Haskeline.History (History, addHistory, emptyHistory) - -import Test.QuickCheck (Arbitrary(..)) - -instance Arbitrary Interrupt where - arbitrary = pure Interrupt - --- instance Arbitrary Prefs - -instance Arbitrary Completion where - arbitrary = Completion <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary History where - arbitrary = addHistory <$> arbitrary <@> emptyHistory +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.System.Console.Haskeline+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @haskeline@ library.+-}+module Instances.System.Console.Haskeline () where++import Instances.Utils ((<@>))++import Prelude ()+import Prelude.Compat++import System.Console.Haskeline (Interrupt(..))+import System.Console.Haskeline.Completion (Completion(..))+import System.Console.Haskeline.History (History, addHistory, emptyHistory)++import Test.QuickCheck (Arbitrary(..))++instance Arbitrary Interrupt where+ arbitrary = pure Interrupt++-- instance Arbitrary Prefs++instance Arbitrary Completion where+ arbitrary = Completion <$> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary History where+ arbitrary = addHistory <$> arbitrary <@> emptyHistory
tests/Instances/System/Console/Terminfo.hs view
@@ -1,40 +1,40 @@-{-# LANGUAGE CPP #-} - -#if !defined(mingw32_HOST_OS) -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Instances.System.Console.Terminfo -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @terminfo@ library. --} -module Instances.System.Console.Terminfo () where - -#if !defined(mingw32_HOST_OS) -import Prelude () -import Prelude.Compat - -import System.Console.Terminfo.Color (Color(..)) - -import Test.QuickCheck (Arbitrary(..), oneof) - -instance Arbitrary Color where - arbitrary = oneof [ pure Black - , pure Red - , pure Green - , pure Yellow - , pure Blue - , pure Magenta - , pure Cyan - , pure White - , ColorNumber <$> arbitrary - ] - --- instance Arbitrary SetupTermError -#endif +{-# LANGUAGE CPP #-}++#if !defined(mingw32_HOST_OS)+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Instances.System.Console.Terminfo+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @terminfo@ library.+-}+module Instances.System.Console.Terminfo () where++#if !defined(mingw32_HOST_OS)+import Prelude ()+import Prelude.Compat++import System.Console.Terminfo.Color (Color(..))++import Test.QuickCheck (Arbitrary(..), oneof)++instance Arbitrary Color where+ arbitrary = oneof [ pure Black+ , pure Red+ , pure Green+ , pure Yellow+ , pure Blue+ , pure Magenta+ , pure Cyan+ , pure White+ , ColorNumber <$> arbitrary+ ]++-- instance Arbitrary SetupTermError+#endif
tests/Instances/System/Directory.hs view
@@ -1,31 +1,31 @@-{-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.System.Directory -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for 'Permissions'. --} -module Instances.System.Directory () where - -#if MIN_VERSION_directory(1,1,0) -import Control.Applicative ((<**>)) - -import Prelude () -import Prelude.Compat - -import System.Directory (Permissions, emptyPermissions, setOwnerReadable, - setOwnerWritable, setOwnerExecutable, setOwnerSearchable) - -import Test.QuickCheck (Arbitrary(..)) - -instance Arbitrary Permissions where - arbitrary = ($ emptyPermissions) <$> (setOwnerReadable <$> arbitrary) - <**> (setOwnerWritable <$> arbitrary) - <**> (setOwnerExecutable <$> arbitrary) - <**> (setOwnerSearchable <$> arbitrary) -#endif +{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.System.Directory+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 'Permissions'.+-}+module Instances.System.Directory () where++#if MIN_VERSION_directory(1,1,0)+import Control.Applicative ((<**>))++import Prelude ()+import Prelude.Compat++import System.Directory (Permissions, emptyPermissions, setOwnerReadable,+ setOwnerWritable, setOwnerExecutable, setOwnerSearchable)++import Test.QuickCheck (Arbitrary(..))++instance Arbitrary Permissions where+ arbitrary = ($ emptyPermissions) <$> (setOwnerReadable <$> arbitrary)+ <**> (setOwnerWritable <$> arbitrary)+ <**> (setOwnerExecutable <$> arbitrary)+ <**> (setOwnerSearchable <$> arbitrary)+#endif
tests/Instances/System/Locale.hs view
@@ -1,23 +1,23 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.System.Locale -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for old 'TimeLocale' values. --} -module Instances.System.Locale () where - -import Prelude () -import Prelude.Compat - -import System.Locale (TimeLocale(..)) - -import Test.QuickCheck (Arbitrary(..)) - -instance Arbitrary TimeLocale where - arbitrary = TimeLocale <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.System.Locale+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 old 'TimeLocale' values.+-}+module Instances.System.Locale () where++import Prelude ()+import Prelude.Compat++import System.Locale (TimeLocale(..))++import Test.QuickCheck (Arbitrary(..))++instance Arbitrary TimeLocale where+ arbitrary = TimeLocale <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
tests/Instances/System/Posix.hs view
@@ -1,56 +1,56 @@-{-# LANGUAGE CPP #-} - -#if !defined(mingw32_HOST_OS) -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Instances.System.Posix -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @unix@ library. --} -module Instances.System.Posix () where - -#if !defined(mingw32_HOST_OS) -import Instances.Miscellaneous () - -import Prelude () -import Prelude.Compat - -import System.Posix.DynamicLinker (RTLDFlags(..), DL(..)) -import System.Posix.Process (ProcessStatus(..)) -import System.Posix.User (GroupEntry(..), UserEntry(..)) - -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) - -deriving instance Bounded RTLDFlags -deriving instance Enum RTLDFlags -instance Arbitrary RTLDFlags where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary DL where - arbitrary = oneof [pure Null, pure Next, pure Default, DLHandle <$> arbitrary] - -instance Arbitrary ProcessStatus where - arbitrary = oneof [ Exited <$> arbitrary -# if MIN_VERSION_unix(2,7,0) - , Terminated <$> arbitrary <*> arbitrary -# else - , Terminated <$> arbitrary -# endif - , Stopped <$> arbitrary - ] - -instance Arbitrary GroupEntry where - arbitrary = GroupEntry <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary UserEntry where - arbitrary = UserEntry <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary -#endif +{-# LANGUAGE CPP #-}++#if !defined(mingw32_HOST_OS)+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Instances.System.Posix+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @unix@ library.+-}+module Instances.System.Posix () where++#if !defined(mingw32_HOST_OS)+import Instances.Miscellaneous ()++import Prelude ()+import Prelude.Compat++import System.Posix.DynamicLinker (RTLDFlags(..), DL(..))+import System.Posix.Process (ProcessStatus(..))+import System.Posix.User (GroupEntry(..), UserEntry(..))++import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)++deriving instance Bounded RTLDFlags+deriving instance Enum RTLDFlags+instance Arbitrary RTLDFlags where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary DL where+ arbitrary = oneof [pure Null, pure Next, pure Default, DLHandle <$> arbitrary]++instance Arbitrary ProcessStatus where+ arbitrary = oneof [ Exited <$> arbitrary+# if MIN_VERSION_unix(2,7,0)+ , Terminated <$> arbitrary <*> arbitrary+# else+ , Terminated <$> arbitrary+# endif+ , Stopped <$> arbitrary+ ]++instance Arbitrary GroupEntry where+ arbitrary = GroupEntry <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary UserEntry where+ arbitrary = UserEntry <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary+#endif
tests/Instances/System/Random.hs view
@@ -1,22 +1,22 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.System.Random -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides an 'Arbitrary' instance for 'StdGen' values. --} -module Instances.System.Random () where - -import Prelude () -import Prelude.Compat - -import System.Random (StdGen, mkStdGen) - -import Test.QuickCheck (Arbitrary(..)) - -instance Arbitrary StdGen where - arbitrary = mkStdGen <$> arbitrary +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.System.Random+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 'StdGen' values.+-}+module Instances.System.Random () where++import Prelude ()+import Prelude.Compat++import System.Random (StdGen, mkStdGen)++import Test.QuickCheck (Arbitrary(..))++instance Arbitrary StdGen where+ arbitrary = mkStdGen <$> arbitrary
tests/Instances/System/Win32.hs view
@@ -1,109 +1,109 @@-{-# LANGUAGE CPP #-} - -#if defined(mingw32_HOST_OS) -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -#endif - -{-| -Module: Instances.System.Win32 -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @Win32@ library. --} -module Instances.System.Win32 () where - -#if defined(mingw32_HOST_OS) -import Instances.Miscellaneous () - -import Prelude () -import Prelude.Compat - -import System.Win32.DebugApi (DebugEventInfo(..), Exception(..)) -import System.Win32.File (BY_HANDLE_FILE_INFORMATION(..), WIN32_FILE_ATTRIBUTE_DATA(..)) -import System.Win32.Info (ProcessorArchitecture(..), SYSTEM_INFO(..)) -import System.Win32.Time (FILETIME(..), SYSTEMTIME(..), - TIME_ZONE_INFORMATION(..), TimeZoneId(..)) - -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) - -instance Arbitrary DebugEventInfo where - arbitrary = oneof [ pure UnknownDebugEvent - , Exception <$> arbitrary <*> arbitrary - , CreateThread <$> arbitrary - , CreateProcess <$> arbitrary <*> arbitrary <*> arbitrary - , ExitThread <$> arbitrary - , ExitProcess <$> arbitrary - , LoadDll <$> arbitrary - , UnloadDll <$> arbitrary - , DebugString <$> arbitrary <*> arbitrary <*> arbitrary - ] - -instance Arbitrary Exception where - arbitrary = oneof [ pure UnknownException - , AccessViolation <$> arbitrary <*> arbitrary - , pure ArrayBoundsExceeded - , pure Breakpoint - , pure DataTypeMisalignment - , pure FltDenormalOperand - , pure FltDivideByZero - , pure FltInexactResult - , pure FltInvalidOperation - , pure FltOverflow - , pure FltStackCheck - , pure FltUnderflow - , pure IllegalInstruction - , pure InPageError - , pure IntDivideByZero - , pure IntOverflow - , pure InvalidDisposition - , pure NonContinuable - , pure PrivilegedInstruction - , pure SingleStep - , pure StackOverflow - ] - -instance Arbitrary BY_HANDLE_FILE_INFORMATION where - arbitrary = BY_HANDLE_FILE_INFORMATION <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary WIN32_FILE_ATTRIBUTE_DATA where - arbitrary = WIN32_FILE_ATTRIBUTE_DATA <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary - -instance Arbitrary ProcessorArchitecture where - arbitrary = oneof [ PaUnknown <$> arbitrary - , pure PaIntel - , pure PaMips - , pure PaAlpha - , pure PaPpc - , pure PaIa64 - , pure PaIa32OnIa64 - , pure PaAmd64 - ] - -instance Arbitrary SYSTEM_INFO where - arbitrary = SYSTEM_INFO <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary - -deriving instance Arbitrary FILETIME - -instance Arbitrary SYSTEMTIME where - arbitrary = SYSTEMTIME <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary TIME_ZONE_INFORMATION where - arbitrary = TIME_ZONE_INFORMATION <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary <*> arbitrary - -deriving instance Bounded TimeZoneId -deriving instance Enum TimeZoneId -instance Arbitrary TimeZoneId where - arbitrary = arbitraryBoundedEnum -#endif +{-# LANGUAGE CPP #-}++#if defined(mingw32_HOST_OS)+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif++{-|+Module: Instances.System.Win32+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @Win32@ library.+-}+module Instances.System.Win32 () where++#if defined(mingw32_HOST_OS)+import Instances.Miscellaneous ()++import Prelude ()+import Prelude.Compat++import System.Win32.DebugApi (DebugEventInfo(..), Exception(..))+import System.Win32.File (BY_HANDLE_FILE_INFORMATION(..), WIN32_FILE_ATTRIBUTE_DATA(..))+import System.Win32.Info (ProcessorArchitecture(..), SYSTEM_INFO(..))+import System.Win32.Time (FILETIME(..), SYSTEMTIME(..),+ TIME_ZONE_INFORMATION(..), TimeZoneId(..))++import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)++instance Arbitrary DebugEventInfo where+ arbitrary = oneof [ pure UnknownDebugEvent+ , Exception <$> arbitrary <*> arbitrary+ , CreateThread <$> arbitrary+ , CreateProcess <$> arbitrary <*> arbitrary <*> arbitrary+ , ExitThread <$> arbitrary+ , ExitProcess <$> arbitrary+ , LoadDll <$> arbitrary+ , UnloadDll <$> arbitrary+ , DebugString <$> arbitrary <*> arbitrary <*> arbitrary+ ]++instance Arbitrary Exception where+ arbitrary = oneof [ pure UnknownException+ , AccessViolation <$> arbitrary <*> arbitrary+ , pure ArrayBoundsExceeded+ , pure Breakpoint+ , pure DataTypeMisalignment+ , pure FltDenormalOperand+ , pure FltDivideByZero+ , pure FltInexactResult+ , pure FltInvalidOperation+ , pure FltOverflow+ , pure FltStackCheck+ , pure FltUnderflow+ , pure IllegalInstruction+ , pure InPageError+ , pure IntDivideByZero+ , pure IntOverflow+ , pure InvalidDisposition+ , pure NonContinuable+ , pure PrivilegedInstruction+ , pure SingleStep+ , pure StackOverflow+ ]++instance Arbitrary BY_HANDLE_FILE_INFORMATION where+ arbitrary = BY_HANDLE_FILE_INFORMATION <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary WIN32_FILE_ATTRIBUTE_DATA where+ arbitrary = WIN32_FILE_ATTRIBUTE_DATA <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary++instance Arbitrary ProcessorArchitecture where+ arbitrary = oneof [ PaUnknown <$> arbitrary+ , pure PaIntel+ , pure PaMips+ , pure PaAlpha+ , pure PaPpc+ , pure PaIa64+ , pure PaIa32OnIa64+ , pure PaAmd64+ ]++instance Arbitrary SYSTEM_INFO where+ arbitrary = SYSTEM_INFO <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary++deriving instance Arbitrary FILETIME++instance Arbitrary SYSTEMTIME where+ arbitrary = SYSTEMTIME <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary TIME_ZONE_INFORMATION where+ arbitrary = TIME_ZONE_INFORMATION <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary <*> arbitrary++deriving instance Bounded TimeZoneId+deriving instance Enum TimeZoneId+instance Arbitrary TimeZoneId where+ arbitrary = arbitraryBoundedEnum+#endif
tests/Instances/Text/PrettyPrint.hs view
@@ -1,48 +1,48 @@-{-# LANGUAGE CPP #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Text.PrettyPrint -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @pretty@ library -(as well as 'Show' instances if using an old version of @pretty@). --} -module Instances.Text.PrettyPrint () where - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) - -import Text.PrettyPrint.HughesPJ (Doc, Mode(..), Style(..), TextDetails(..), text) -#if MIN_VERSION_pretty(1,1,2) -import Text.PrettyPrint.HughesPJClass (PrettyLevel(..)) -#endif - -instance Arbitrary Doc where - arbitrary = text <$> arbitrary - -deriving instance Bounded Mode -deriving instance Enum Mode -instance Arbitrary Mode where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Style where - arbitrary = Style <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary TextDetails where - arbitrary = oneof [Chr <$> arbitrary, Str <$> arbitrary, PStr <$> arbitrary] - -#if MIN_VERSION_pretty(1,1,2) -deriving instance Arbitrary PrettyLevel -#else -deriving instance Show Mode -deriving instance Show Style -deriving instance Show TextDetails -#endif +{-# LANGUAGE CPP #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Text.PrettyPrint+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @pretty@ library+(as well as 'Show' instances if using an old version of @pretty@).+-}+module Instances.Text.PrettyPrint () where++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)++import Text.PrettyPrint.HughesPJ (Doc, Mode(..), Style(..), TextDetails(..), text)+#if MIN_VERSION_pretty(1,1,2)+import Text.PrettyPrint.HughesPJClass (PrettyLevel(..))+#endif++instance Arbitrary Doc where+ arbitrary = text <$> arbitrary++deriving instance Bounded Mode+deriving instance Enum Mode+instance Arbitrary Mode where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Style where+ arbitrary = Style <$> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary TextDetails where+ arbitrary = oneof [Chr <$> arbitrary, Str <$> arbitrary, PStr <$> arbitrary]++#if MIN_VERSION_pretty(1,1,2)+deriving instance Arbitrary PrettyLevel+#else+deriving instance Show Mode+deriving instance Show Style+deriving instance Show TextDetails+#endif
tests/Instances/Text/XHtml.hs view
@@ -1,32 +1,32 @@-{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Text.XHtml -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @xhtml@ library. --} -module Instances.Text.XHtml () where - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), Gen) - -import Text.XHtml.Frameset (Html, HtmlAttr, HotLink(..), strAttr, toHtml) -import Text.XHtml.Table (HtmlTable, cell) - -instance Arbitrary Html where - arbitrary = toHtml <$> (arbitrary :: Gen String) - -instance Arbitrary HtmlAttr where - arbitrary = strAttr <$> arbitrary <*> arbitrary - -instance Arbitrary HotLink where - arbitrary = HotLink <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary HtmlTable where - arbitrary = cell <$> (arbitrary :: Gen Html) +{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Text.XHtml+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @xhtml@ library.+-}+module Instances.Text.XHtml () where++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), Gen)++import Text.XHtml.Frameset (Html, HtmlAttr, HotLink(..), strAttr, toHtml)+import Text.XHtml.Table (HtmlTable, cell)++instance Arbitrary Html where+ arbitrary = toHtml <$> (arbitrary :: Gen String)++instance Arbitrary HtmlAttr where+ arbitrary = strAttr <$> arbitrary <*> arbitrary++instance Arbitrary HotLink where+ arbitrary = HotLink <$> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary HtmlTable where+ arbitrary = cell <$> (arbitrary :: Gen Html)
tests/Instances/Trace/Hpc.hs view
@@ -1,63 +1,63 @@-{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} -{-| -Module: Instances.Trace.Hpc -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -Provides 'Arbitrary' instances for data types in the @hpc@ library. --} -module Instances.Trace.Hpc () where - -import Instances.Utils ((<@>)) - -import Prelude () -import Prelude.Compat - -import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) -import Test.QuickCheck.Instances () - -import Trace.Hpc.Mix (Mix(..), MixEntry, BoxLabel(..), CondBox(..)) -import Trace.Hpc.Tix (Tix(..), TixModule(..)) -import Trace.Hpc.Util (HpcPos, Hash, toHpcPos) - -instance Arbitrary Mix where - arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary <@> [fMixEntry] --- arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary --- <*> arbitrary <*> arbitrary - -instance Arbitrary BoxLabel where - arbitrary = oneof [ ExpBox <$> arbitrary - , TopLevelBox <$> arbitrary - , LocalBox <$> arbitrary - , BinBox <$> arbitrary <*> arbitrary - ] - -deriving instance Bounded CondBox -deriving instance Enum CondBox -instance Arbitrary CondBox where - arbitrary = arbitraryBoundedEnum - -instance Arbitrary Tix where - arbitrary = Tix <$> arbitrary - -instance Arbitrary TixModule where - arbitrary = TixModule <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary HpcPos where - arbitrary = toHpcPos <$> ((,,,) <$> arbitrary <*> arbitrary - <*> arbitrary <*> arbitrary) - -instance Arbitrary Hash where - arbitrary = fromInteger <$> arbitrary - -------------------------------------------------------------------------------- --- Workarounds to make Arbitrary instances faster -------------------------------------------------------------------------------- - -fMixEntry :: MixEntry -fMixEntry = (toHpcPos (0, 1, 2, 3), ExpBox True) +{-# LANGUAGE StandaloneDeriving #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+Module: Instances.Trace.Hpc+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++Provides 'Arbitrary' instances for data types in the @hpc@ library.+-}+module Instances.Trace.Hpc () where++import Instances.Utils ((<@>))++import Prelude ()+import Prelude.Compat++import Test.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof)+import Test.QuickCheck.Instances ()++import Trace.Hpc.Mix (Mix(..), MixEntry, BoxLabel(..), CondBox(..))+import Trace.Hpc.Tix (Tix(..), TixModule(..))+import Trace.Hpc.Util (HpcPos, Hash, toHpcPos)++instance Arbitrary Mix where+ arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <@> [fMixEntry]+-- arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary+-- <*> arbitrary <*> arbitrary++instance Arbitrary BoxLabel where+ arbitrary = oneof [ ExpBox <$> arbitrary+ , TopLevelBox <$> arbitrary+ , LocalBox <$> arbitrary+ , BinBox <$> arbitrary <*> arbitrary+ ]++deriving instance Bounded CondBox+deriving instance Enum CondBox+instance Arbitrary CondBox where+ arbitrary = arbitraryBoundedEnum++instance Arbitrary Tix where+ arbitrary = Tix <$> arbitrary++instance Arbitrary TixModule where+ arbitrary = TixModule <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary++instance Arbitrary HpcPos where+ arbitrary = toHpcPos <$> ((,,,) <$> arbitrary <*> arbitrary+ <*> arbitrary <*> arbitrary)++instance Arbitrary Hash where+ arbitrary = fromInteger <$> arbitrary++-------------------------------------------------------------------------------+-- Workarounds to make Arbitrary instances faster+-------------------------------------------------------------------------------++fMixEntry :: MixEntry+fMixEntry = (toHpcPos (0, 1, 2, 3), ExpBox True)
tests/Instances/Utils.hs view
@@ -1,16 +1,16 @@-{-| -Module: Instances.Utils -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -A collection of utility functions. --} -module Instances.Utils ((<@>)) where - -infixl 4 <@> --- | A useful way to escape a 'Functor' context. -(<@>) :: Functor f => f (a -> b) -> a -> f b -f <@> x = fmap ($ x) f +{-|+Module: Instances.Utils+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++A collection of utility functions.+-}+module Instances.Utils ((<@>)) where++infixl 4 <@>+-- | A useful way to escape a 'Functor' context.+(<@>) :: Functor f => f (a -> b) -> a -> f b+f <@> x = fmap ($ x) f
tests/Spec/Compiler/HooplSpec.hs view
@@ -1,40 +1,50 @@-{-| -Module: Spec.Compiler.HooplSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @hoopl@ library. --} -module Spec.Compiler.HooplSpec (main, spec) where - -import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed, - Unique, UniqueMap, UniqueSet, C) -import Compiler.Hoopl.Passes.Dominator (DominatorNode, DominatorTree, DPath) - -import Instances.Compiler.Hoopl () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Compiler.Hoopl () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Compiler.Hoopl" $ do - prop "Label instance" (prop_matchesShow :: Int -> Label -> Bool) - prop "LabelMap Char instance" (prop_matchesShow :: Int -> LabelMap Char -> Bool) - prop "LabelSet instance" (prop_matchesShow :: Int -> LabelSet -> Bool) - prop "Pointed C C Int instance" (prop_matchesShow :: Int -> Pointed C C Int -> Bool) - prop "Unique instance" (prop_matchesShow :: Int -> Unique -> Bool) - prop "UniqueMap Char instance" (prop_matchesShow :: Int -> UniqueMap Char -> Bool) - prop "UniqueSet instance" (prop_matchesShow :: Int -> UniqueSet -> Bool) - prop "DominatorNode instance" (prop_matchesShow :: Int -> DominatorNode -> Bool) - prop "DominatorTree instance" (prop_matchesShow :: Int -> DominatorTree -> Bool) - prop "DPath instance" (prop_matchesShow :: Int -> DPath -> Bool)+{-|+Module: Spec.Compiler.HooplSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @hoopl@ library.+-}+module Spec.Compiler.HooplSpec (main, spec) where++import Compiler.Hoopl (Label, LabelMap, LabelSet, Pointed,+ Unique, UniqueMap, UniqueSet, C)+import Compiler.Hoopl.Passes.Dominator (DominatorNode, DominatorTree, DPath)++import Instances.Compiler.Hoopl ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Compiler.Hoopl ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Label" $+ prop "Show instance" (prop_matchesShow :: Int -> Label -> Bool)+ describe "LabelMap Char" $+ prop "Show instance" (prop_matchesShow :: Int -> LabelMap Char -> Bool)+ describe "LabelSet" $+ prop "Show instance" (prop_matchesShow :: Int -> LabelSet -> Bool)+ describe "Pointed C C Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Pointed C C Int -> Bool)+ describe "Unique" $+ prop "Show instance" (prop_matchesShow :: Int -> Unique -> Bool)+ describe "UniqueMap Char" $+ prop "Show instance" (prop_matchesShow :: Int -> UniqueMap Char -> Bool)+ describe "UniqueSet" $+ prop "Show instance" (prop_matchesShow :: Int -> UniqueSet -> Bool)+ describe "DominatorNode" $+ prop "Show instance" (prop_matchesShow :: Int -> DominatorNode -> Bool)+ describe "DominatorTree" $+ prop "Show instance" (prop_matchesShow :: Int -> DominatorTree -> Bool)+ describe "DPath" $+ prop "Show instance" (prop_matchesShow :: Int -> DPath -> Bool)
tests/Spec/Control/Applicative/TransSpec.hs view
@@ -1,31 +1,33 @@-{-| -Module: Spec.Control.Applicative.TransSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for applicative functor transformers. --} -module Spec.Control.Applicative.TransSpec (main, spec) where - -import Control.Applicative.Backwards (Backwards) -import Control.Applicative.Lift (Lift) - -import Instances.Control.Applicative.Trans () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Control.Applicative.Trans () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Control.Applicative.Trans" $ do - prop "Backwards Maybe Int instance" (prop_matchesShow :: Int -> Backwards Maybe Int -> Bool) - prop "Lift Maybe Int instance" (prop_matchesShow :: Int -> Lift Maybe Int -> Bool) +{-|+Module: Spec.Control.Applicative.TransSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for applicative functor transformers.+-}+module Spec.Control.Applicative.TransSpec (main, spec) where++import Control.Applicative.Backwards (Backwards)+import Control.Applicative.Lift (Lift)++import Instances.Control.Applicative.Trans ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Control.Applicative.Trans ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Backwards Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Backwards Maybe Int -> Bool)+ describe "Lift Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Lift Maybe Int -> Bool)
tests/Spec/Control/Monad/TransSpec.hs view
@@ -1,42 +1,49 @@-{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} -{-| -Module: Spec.Control.Monad.TransSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for monad transformers. --} -module Spec.Control.Monad.TransSpec (main, spec) where - -import Control.Monad.Trans.Error (ErrorT) -import Control.Monad.Trans.Except (ExceptT) -import Control.Monad.Trans.Identity (IdentityT) -import Control.Monad.Trans.List (ListT) -import Control.Monad.Trans.Maybe (MaybeT) -import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT) -import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT) - -import Instances.Control.Monad.Trans () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Control.Monad.Trans () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Control.Monad.Trans" $ do - prop "ErrorT Char Maybe Int instance" (prop_matchesShow :: Int -> ErrorT Char Maybe Int -> Bool) - prop "ExceptT Char Maybe Int instance" (prop_matchesShow :: Int -> ExceptT Char Maybe Int -> Bool) - prop "IdentityT Maybe Int instance" (prop_matchesShow :: Int -> IdentityT Maybe Int -> Bool) - prop "ListT Maybe Char instance" (prop_matchesShow :: Int -> ListT Maybe Char -> Bool) - prop "Maybe [] Int instance" (prop_matchesShow :: Int -> MaybeT [] Int -> Bool) - prop "lazy WriterT String Maybe Int instance" (prop_matchesShow :: Int -> WL.WriterT String Maybe Int -> Bool) - prop "strict WriterT String Maybe Int instance" (prop_matchesShow :: Int -> WS.WriterT String Maybe Int -> Bool) +{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}+{-|+Module: Spec.Control.Monad.TransSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for monad transformers.+-}+module Spec.Control.Monad.TransSpec (main, spec) where++import Control.Monad.Trans.Error (ErrorT)+import Control.Monad.Trans.Except (ExceptT)+import Control.Monad.Trans.Identity (IdentityT)+import Control.Monad.Trans.List (ListT)+import Control.Monad.Trans.Maybe (MaybeT)+import qualified Control.Monad.Trans.Writer.Lazy as WL (WriterT)+import qualified Control.Monad.Trans.Writer.Strict as WS (WriterT)++import Instances.Control.Monad.Trans ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Control.Monad.Trans ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "ErrorT Char Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> ErrorT Char Maybe Int -> Bool)+ describe "ExceptT Char Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> ExceptT Char Maybe Int -> Bool)+ describe "IdentityT Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> IdentityT Maybe Int -> Bool)+ describe "ListT Maybe Char" $+ prop "Show instance" (prop_matchesShow :: Int -> ListT Maybe Char -> Bool)+ describe "Maybe [] Int" $+ prop "Show instance" (prop_matchesShow :: Int -> MaybeT [] Int -> Bool)+ describe "lazy WriterT String Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> WL.WriterT String Maybe Int -> Bool)+ describe "strict WriterT String Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> WS.WriterT String Maybe Int -> Bool)
+ tests/Spec/Data/BifunctorSpec.hs view
@@ -0,0 +1,51 @@+{-|+Module: Spec.Data.BifunctorSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @bifunctors@ library.+-}+module Spec.Data.BifunctorSpec (main, spec) where++import Data.Bifunctor.Biff (Biff)+import Data.Bifunctor.Clown (Clown)+import Data.Bifunctor.Flip (Flip)+import Data.Bifunctor.Join (Join)+import Data.Bifunctor.Joker (Joker)+import Data.Bifunctor.Product (Product)+import Data.Bifunctor.Tannen (Tannen)+import Data.Bifunctor.Wrapped (WrappedBifunctor)++import Instances.Data.Bifunctor ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.Bifunctor ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Biff Either [] Maybe Char Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Biff Either [] Maybe Char Int -> Bool)+ describe "Clown [] Char Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Clown [] Char Int -> Bool)+ describe "Flip Either Int Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Flip Either Int Char -> Bool)+ describe "Join Either Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Join Either Int -> Bool)+ describe "Joker [] Char Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Joker [] Char Int -> Bool)+ describe "Product Either ((,,) Bool) Int Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Product Either ((,,) Bool) Int Char -> Bool)+ describe "Tannen Maybe Either Int Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Tannen Maybe Either Int Char -> Bool)+ describe "WrappedBifunctor Either Int Char" $+ prop "Show instance" (prop_matchesShow :: Int -> WrappedBifunctor Either Int Char -> Bool)
tests/Spec/Data/BinarySpec.hs view
@@ -1,29 +1,29 @@-{-| -Module: Spec.Data.BinarySpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'Decoder's. --} -module Spec.Data.BinarySpec (main, spec) where - -import Data.Binary.Get.Internal (Decoder) - -import Instances.Data.Binary () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Data.Binary () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Binary" $ - prop "Decoder Int instance" (prop_matchesShow :: Int -> Decoder Int -> Bool) +{-|+Module: Spec.Data.BinarySpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for 'Decoder's.+-}+module Spec.Data.BinarySpec (main, spec) where++import Data.Binary.Get.Internal (Decoder)++import Instances.Data.Binary ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.Binary ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel . describe "Decoder Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Decoder Int -> Bool)
tests/Spec/Data/ContainersSpec.hs view
@@ -1,42 +1,50 @@-{-| -Module: Spec.Data.ContainersSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @containers@ library. --} -module Spec.Data.ContainersSpec (main, spec) where - -import Data.IntMap (IntMap) -import Data.IntSet (IntSet) -import Data.Map (Map) -import Data.Sequence (Seq, ViewL, ViewR) -import Data.Set (Set) -import Data.Tree (Tree) - -import Instances.Data.Containers () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck.Instances () - -import Text.Show.Text.Data.Containers () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Containers" $ do - prop "IntMap Char instance" (prop_matchesShow :: Int -> IntMap Char -> Bool) - prop "IntSet instance" (prop_matchesShow :: Int -> IntSet -> Bool) - prop "Map Char Char instance" (prop_matchesShow :: Int -> Map Char Char -> Bool) - prop "Sequence Char" (prop_matchesShow :: Int -> Seq Char -> Bool) - prop "ViewL Int instance" (prop_matchesShow :: Int -> ViewL Int -> Bool) - prop "ViewR Int instance" (prop_matchesShow :: Int -> ViewR Int -> Bool) - prop "Set Char instance" (prop_matchesShow :: Int -> Set Char -> Bool) - prop "Tree Char instance" (prop_matchesShow :: Int -> Tree Char -> Bool) +{-|+Module: Spec.Data.ContainersSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @containers@ library.+-}+module Spec.Data.ContainersSpec (main, spec) where++import Data.IntMap (IntMap)+import Data.IntSet (IntSet)+import Data.Map (Map)+import Data.Sequence (Seq, ViewL, ViewR)+import Data.Set (Set)+import Data.Tree (Tree)++import Instances.Data.Containers ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)+import Test.QuickCheck.Instances ()++import Text.Show.Text.Data.Containers ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "IntMap Char" $+ prop "Show instance" (prop_matchesShow :: Int -> IntMap Char -> Bool)+ describe "IntSet" $+ prop "Show instance" (prop_matchesShow :: Int -> IntSet -> Bool)+ describe "Map Char Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Map Char Char -> Bool)+ describe "Sequence Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Seq Char -> Bool)+ describe "ViewL Char" $+ prop "Show instance" (prop_matchesShow :: Int -> ViewL Char -> Bool)+ describe "ViewR Char" $+ prop "Show instance" (prop_matchesShow :: Int -> ViewR Char -> Bool)+ describe "Set Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Set Char -> Bool)+ describe "Tree Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Tree Char -> Bool)
tests/Spec/Data/Functor/TransSpec.hs view
@@ -1,37 +1,42 @@-{-| -Module: Spec.Data.Functor.TransSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for functor transformers. --} -module Spec.Data.Functor.TransSpec (main, spec) 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 Instances.Data.Functor.Trans () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Data.Functor.Trans () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Functor.Trans" $ do - prop "Compose Maybe [] Char instance" (prop_matchesShow :: Int -> Compose Maybe [] Char -> Bool) - prop "Constant Int Char instance" (prop_matchesShow :: Int -> Constant Int Char -> Bool) - prop "Product Maybe [] Char instance" (prop_matchesShow :: Int -> Product Maybe [] Char -> Bool) - prop "Reverse Maybe Int instance" (prop_matchesShow :: Int -> Reverse Maybe Int -> Bool) - prop "Sum Maybe [] Char instance" (prop_matchesShow :: Int -> Sum Maybe [] Char -> Bool) +{-|+Module: Spec.Data.Functor.TransSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for functor transformers.+-}+module Spec.Data.Functor.TransSpec (main, spec) 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 Instances.Data.Functor.Trans ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.Functor.Trans ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Compose Maybe (Either Int) Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Compose Maybe (Either Int) Char -> Bool)+ describe "Constant Int Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Constant Int Char -> Bool)+ describe "Product Maybe (Either Int) Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Product Maybe (Either Int) Char -> Bool)+ describe "Reverse Maybe Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Reverse Maybe Int -> Bool)+ describe "Sum Maybe (Either Int) Char" $+ prop "Show instance" (prop_matchesShow :: Int -> Sum Maybe (Either Int) Char -> Bool)
tests/Spec/Data/List/NonEmptySpec.hs view
@@ -1,29 +1,31 @@-{-| -Module: Spec.Data.List.NonEmptySpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -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_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Data.List.NonEmpty () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.List.NonEmpty" $ - prop "NonEmpty Char instance" (prop_matchesShow :: Int -> NonEmpty Char -> Bool) +{-|+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_matchesShow, prop_genericShow, prop_genericShow1)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.List.NonEmpty ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel . describe "NonEmpty Char" $ do+ prop "Show instance" (prop_matchesShow :: Int -> NonEmpty Char -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> NonEmpty Char -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> NonEmpty Char -> Bool)
tests/Spec/Data/SemigroupSpec.hs view
@@ -1,35 +1,56 @@-{-| -Module: Spec.Data.SemigroupSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -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_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Data.Semigroup () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Semigroup" $ do - prop "Min Int instance" (prop_matchesShow :: Int -> Min Int -> Bool) - prop "Max Int instance" (prop_matchesShow :: Int -> Max Int -> Bool) - prop "First Int instance" (prop_matchesShow :: Int -> First Int -> Bool) - prop "Last Int Char" (prop_matchesShow :: Int -> Last Int -> Bool) - prop "WrappedMonoid Int instance" (prop_matchesShow :: Int -> WrappedMonoid Int -> Bool) - prop "Option Int instance" (prop_matchesShow :: Int -> Option Int -> Bool) - prop "Arg Int Int instance" (prop_matchesShow :: Int -> Arg Int Int -> Bool) +{-|+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_matchesShow, prop_genericShow, prop_genericShow1)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.Semigroup ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Min Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Min Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Min Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> Min Int -> Bool)+ describe "Max Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Max Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Max Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> Max Int -> Bool)+ describe "First Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> First Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> First Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> First Int -> Bool)+ describe "Last Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Last Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Last Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> Last Int -> Bool)+ describe "WrappedMonoid Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> WrappedMonoid Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> WrappedMonoid Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> WrappedMonoid Int -> Bool)+ describe "Option Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Option Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Option Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> Option Int -> Bool)+ describe "Arg Int Int" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Arg Int Int -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Arg Int Int -> Bool)+ prop "generic Show1" (prop_genericShow1 :: Int -> Arg Int Int -> Bool)
− tests/Spec/Data/String/UTF8Spec.hs
@@ -1,35 +0,0 @@-{-| -Module: Spec.Data.String.UTF8Spec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'UTF8' strings. --} -module Spec.Data.String.UTF8Spec (main, spec) where - -import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as BL -import Data.String.UTF8 (UTF8) -import Data.Word (Word8) - -import Instances.Data.String.UTF8 () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck.Instances () - -import Text.Show.Text.Data.String.UTF8 () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.String.UTF8" $ do - prop "UTF8 ByteString (strict) instance" (prop_matchesShow :: Int -> UTF8 BS.ByteString -> Bool) - prop "UTF8 ByteString (lazy) instance" (prop_matchesShow :: Int -> UTF8 BL.ByteString -> Bool) - prop "UTF8 [Word8] instance" (prop_matchesShow :: Int -> UTF8 [Word8] -> Bool)
tests/Spec/Data/TaggedSpec.hs view
@@ -1,29 +1,29 @@-{-| -Module: Spec.Data.TaggedSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'Tagged' values. --} -module Spec.Data.TaggedSpec (main, spec) where - -import Data.Tagged (Tagged) - -import Instances.Data.Tagged () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Data.Tagged () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Tagged" $ - prop "Tagged Char Int instance" (prop_matchesShow :: Int -> Tagged Char Int -> Bool) +{-|+Module: Spec.Data.TaggedSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for 'Tagged' values.+-}+module Spec.Data.TaggedSpec (main, spec) where++import Data.Tagged (Tagged)++import Instances.Data.Tagged ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Data.Tagged ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel . describe "Tagged Char Int" $+ prop "Show instance" (prop_matchesShow :: Int -> Tagged Char Int -> Bool)
tests/Spec/Data/TimeSpec.hs view
@@ -1,39 +1,48 @@-{-| -Module: Spec.Data.TimeSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @time@ library. --} -module Spec.Data.TimeSpec (main, spec) where - -import Data.Time.Calendar (Day) -import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime) -import Data.Time.Clock.TAI (AbsoluteTime) -import Data.Time.LocalTime (TimeZone, TimeOfDay, LocalTime, ZonedTime) - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck.Instances () - -import Text.Show.Text.Data.Time () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.Time" $ do - prop "Day instance" (prop_matchesShow :: Int -> Day -> Bool) - prop "DiffTime instance" (prop_matchesShow :: Int -> DiffTime -> Bool) - prop "UTCTime instance" (prop_matchesShow :: Int -> UTCTime -> Bool) - prop "NominalDiffTime instance" (prop_matchesShow :: Int -> NominalDiffTime -> Bool) - prop "AbsoluteTime instance" (prop_matchesShow :: Int -> AbsoluteTime -> Bool) - prop "TimeZone instance" (prop_matchesShow :: Int -> TimeZone -> Bool) - prop "TimeOfDay instance" (prop_matchesShow :: Int -> TimeOfDay -> Bool) - prop "LocalTime instance" (prop_matchesShow :: Int -> LocalTime -> Bool) - prop "ZonedTime instance" (prop_matchesShow :: Int -> ZonedTime -> Bool) +{-|+Module: Spec.Data.TimeSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @time@ library.+-}+module Spec.Data.TimeSpec (main, spec) where++import Data.Time.Calendar (Day)+import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime)+import Data.Time.Clock.TAI (AbsoluteTime)+import Data.Time.LocalTime (TimeZone, TimeOfDay, LocalTime, ZonedTime)++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)+import Test.QuickCheck.Instances ()++import Text.Show.Text.Data.Time ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Day" $+ prop "Show instance" (prop_matchesShow :: Int -> Day -> Bool)+ describe "DiffTime" $+ prop "Show instance" (prop_matchesShow :: Int -> DiffTime -> Bool)+ describe "UTCTime" $+ prop "Show instance" (prop_matchesShow :: Int -> UTCTime -> Bool)+ describe "NominalDiffTime" $+ prop "Show instance" (prop_matchesShow :: Int -> NominalDiffTime -> Bool)+ describe "AbsoluteTime" $+ prop "Show instance" (prop_matchesShow :: Int -> AbsoluteTime -> Bool)+ describe "TimeZone" $+ prop "Show instance" (prop_matchesShow :: Int -> TimeZone -> Bool)+ describe "TimeOfDay" $+ prop "Show instance" (prop_matchesShow :: Int -> TimeOfDay -> Bool)+ describe "LocalTime" $+ prop "Show instance" (prop_matchesShow :: Int -> LocalTime -> Bool)+ describe "ZonedTime" $+ prop "Show instance" (prop_matchesShow :: Int -> ZonedTime -> Bool)
tests/Spec/Data/UnorderedContainersSpec.hs view
@@ -1,30 +1,32 @@-{-| -Module: Spec.Data.UnorderedContainersSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'HashMap's and 'HashSet's. --} -module Spec.Data.UnorderedContainersSpec (main, spec) where - -import Data.HashMap.Lazy (HashMap) -import Data.HashSet (HashSet) - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck.Instances () - -import Text.Show.Text.Data.UnorderedContainers () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Data.UnorderedContainers" $ do - prop "HashMap Char Char instance" (prop_matchesShow :: Int -> HashMap Char Char -> Bool) - prop "HashSet Char instance" (prop_matchesShow :: Int -> HashSet Char -> Bool) +{-|+Module: Spec.Data.UnorderedContainersSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for 'HashMap's and 'HashSet's.+-}+module Spec.Data.UnorderedContainersSpec (main, spec) where++import Data.HashMap.Lazy (HashMap)+import Data.HashSet (HashSet)++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)+import Test.QuickCheck.Instances ()++import Text.Show.Text.Data.UnorderedContainers ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "HashMap Char Char" $+ prop "Show instance" (prop_matchesShow :: Int -> HashMap Char Char -> Bool)+ describe "HashSet Char" $+ prop "Show instance" (prop_matchesShow :: Int -> HashSet Char -> Bool)
tests/Spec/Language/Haskell/THSpec.hs view
@@ -1,99 +1,187 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.Language.Haskell.THSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@QuickCheck@ properties for data types in the @template-haskell@ library. --} -module Spec.Language.Haskell.THSpec (main, spec) where - -import Instances.Language.Haskell.TH () - -import Language.Haskell.TH.PprLib -import Language.Haskell.TH.Syntax - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text (fromString) -import Text.Show.Text.Language.Haskell.TH (showbName') - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Language.Haskell.TH" $ do -#if MIN_VERSION_template_haskell(2,9,0) - prop "AnnLookup instance" (prop_matchesShow :: Int -> AnnLookup -> Bool) - prop "AnnTarget instance" (prop_matchesShow :: Int -> AnnTarget -> Bool) -#endif - prop "Body instance" (prop_matchesShow :: Int -> Body -> Bool) - prop "Callconv instance" (prop_matchesShow :: Int -> Callconv -> Bool) -#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0)) - prop "ClassInstance instance" (prop_matchesShow :: Int -> ClassInstance -> Bool) -#endif - prop "Clause instance" (prop_matchesShow :: Int -> Clause -> Bool) - prop "Con instance" (prop_matchesShow :: Int -> Con -> Bool) - prop "Dec instance" (prop_matchesShow :: Int -> Dec -> Bool) - prop "Exp instance" (prop_matchesShow :: Int -> Exp -> Bool) - prop "FamFlavour instance" (prop_matchesShow :: Int -> FamFlavour -> Bool) - prop "Fixity instance" (prop_matchesShow :: Int -> Fixity -> Bool) - prop "FixityDirection instance" (prop_matchesShow :: Int -> FixityDirection -> Bool) - prop "Foreign instance" (prop_matchesShow :: Int -> Foreign -> Bool) - prop "FunDep instance" (prop_matchesShow :: Int -> FunDep -> Bool) - prop "Guard instance" (prop_matchesShow :: Int -> Guard -> Bool) - prop "Info instance" (prop_matchesShow :: Int -> Info -> Bool) -#if MIN_VERSION_template_haskell(2,8,0) - prop "Inline instance" (prop_matchesShow :: Int -> Inline -> Bool) -#else - prop "InlineSpec instance" (prop_matchesShow :: Int -> InlineSpec -> Bool) -#endif - prop "Kind instance" (prop_matchesShow :: Int -> Kind -> Bool) - prop "Lit instance" (prop_matchesShow :: Int -> Lit -> Bool) - prop "Loc instance" (prop_matchesShow :: Int -> Loc -> Bool) - prop "Match instance" (prop_matchesShow :: Int -> Match -> Bool) - prop "ModName instance" (prop_matchesShow :: Int -> ModName -> Bool) -#if MIN_VERSION_template_haskell(2,9,0) - prop "Module instance" (prop_matchesShow :: Int -> Module -> Bool) - prop "ModuleInfo instance" (prop_matchesShow :: Int -> ModuleInfo -> Bool) -#endif - prop "Name instance" (prop_matchesShow :: Int -> Name -> Bool) - prop "showbName' output" prop_showName' - prop "OccName instance" (prop_matchesShow :: Int -> OccName -> Bool) - prop "Pat instance" (prop_matchesShow :: Int -> Pat -> Bool) -#if MIN_VERSION_template_haskell(2,8,0) - prop "Phases instance" (prop_matchesShow :: Int -> Phases -> Bool) -#endif - prop "PkgName instance" (prop_matchesShow :: Int -> PkgName -> Bool) - prop "Pred instance" (prop_matchesShow :: Int -> Pred -> Bool) - prop "Pragma instance" (prop_matchesShow :: Int -> Pragma -> Bool) - prop "Range instance" (prop_matchesShow :: Int -> Range -> Bool) -#if MIN_VERSION_template_haskell(2,9,0) - prop "Role instance" (prop_matchesShow :: Int -> Role -> Bool) -#endif -#if MIN_VERSION_template_haskell(2,8,0) - prop "RuleBndr instance" (prop_matchesShow :: Int -> RuleBndr -> Bool) - prop "RuleMatch instance" (prop_matchesShow :: Int -> RuleMatch -> Bool) -#endif - prop "Safety instance" (prop_matchesShow :: Int -> Safety -> Bool) - prop "Stmt instance" (prop_matchesShow :: Int -> Stmt -> Bool) - prop "Strict instance" (prop_matchesShow :: Int -> Strict -> Bool) -#if MIN_VERSION_template_haskell(2,8,0) - prop "TyLit instance" (prop_matchesShow :: Int -> TyLit -> Bool) -#endif - prop "Type instance" (prop_matchesShow :: Int -> Type -> Bool) -#if MIN_VERSION_template_haskell(2,9,0) - prop "TySynEqn instance" (prop_matchesShow :: Int -> TySynEqn -> Bool) -#endif - prop "TyVarBndr instance" (prop_matchesShow :: Int -> TyVarBndr -> Bool) - prop "Doc instance" (prop_matchesShow :: Int -> Doc -> Bool) - --- | Verifies that `showName'` and `showbName'` have the same output. -prop_showName' :: NameIs -> Name -> Bool -prop_showName' nameIs name = fromString (showName' nameIs name) == showbName' nameIs name +{-# LANGUAGE CPP #-}+{-|+Module: Spec.Language.Haskell.THSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@QuickCheck@ properties for data types in the @template-haskell@ library.+-}+module Spec.Language.Haskell.THSpec (main, spec) where++import Instances.Language.Haskell.TH ()++import Language.Haskell.TH.Instances ()+import Language.Haskell.TH.PprLib+import Language.Haskell.TH.Syntax++import Spec.Utils (prop_matchesShow, prop_genericShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text (fromString)+import Text.Show.Text.Language.Haskell.TH (showbName')++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+#if MIN_VERSION_template_haskell(2,9,0)+ describe "AnnLookup" $ do+ prop "Show instance" (prop_matchesShow :: Int -> AnnLookup -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> AnnLookup -> Bool)+ describe "AnnTarget" $ do+ prop "Show instance" (prop_matchesShow :: Int -> AnnTarget -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> AnnTarget -> Bool)+#endif+ describe "Body" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Body -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Body -> Bool)+ describe "Callconv" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Callconv -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Callconv -> Bool)+#if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))+ describe "ClassInstance" $ do+ prop "Show instance" (prop_matchesShow :: Int -> ClassInstance -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> ClassInstance -> Bool)+#endif+ describe "Clause" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Clause -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Clause -> Bool)+ describe "Con" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Con -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Con -> Bool)+ describe "Dec" $ do+ prop "Dec instance" (prop_matchesShow :: Int -> Dec -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Dec -> Bool)+ describe "Doc" $+ prop "Show instance" (prop_matchesShow :: Int -> Doc -> Bool)+ describe "Exp" $ do+ prop "Exp instance" (prop_matchesShow :: Int -> Exp -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Exp -> Bool)+ describe "FamFlavour" $ do+ prop "Show instance" (prop_matchesShow :: Int -> FamFlavour -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> FamFlavour -> Bool)+ describe "Fixity" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Fixity -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Fixity -> Bool)+ describe "FixityDirection" $ do+ prop "Show instance" (prop_matchesShow :: Int -> FixityDirection -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> FixityDirection -> Bool)+ describe "Foreign" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Foreign -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Foreign -> Bool)+ describe "FunDep" $ do+ prop "Show instance" (prop_matchesShow :: Int -> FunDep -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> FunDep -> Bool)+ describe "Guard" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Guard -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Guard -> Bool)+ describe "Info" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Info -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Info -> Bool)+#if MIN_VERSION_template_haskell(2,8,0)+ describe "Inline" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Inline -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Inline -> Bool)+#else+ describe "InlineSpec" $ do+ prop "Show instance" (prop_matchesShow :: Int -> InlineSpec -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> InlineSpec -> Bool)+#endif+ describe "Kind" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Kind -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Kind -> Bool)+ describe "Lit" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Lit -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Lit -> Bool)+ describe "Loc" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Loc -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Loc -> Bool)+ describe "Match" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Match -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Match -> Bool)+ describe "ModName" $ do+ prop "Show instance" (prop_matchesShow :: Int -> ModName -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> ModName -> Bool)+#if MIN_VERSION_template_haskell(2,9,0)+ describe "Module" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Module -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Module -> Bool)+ describe "ModuleInfo" $ do+ prop "Show instance" (prop_matchesShow :: Int -> ModuleInfo -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> ModuleInfo -> Bool)+#endif+ describe "Name" $+ prop "Show instance" (prop_matchesShow :: Int -> Name -> Bool)+ describe "showbName'" $ do+ prop "has the same output as showName" prop_showName'+ describe "OccName" $ do+ prop "Show instance" (prop_matchesShow :: Int -> OccName -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> OccName -> Bool)+ describe "Pat" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Pat -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Pat -> Bool)+#if MIN_VERSION_template_haskell(2,8,0)+ describe "Phases" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Phases -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Phases -> Bool)+#endif+ describe "PkgName" $ do+ prop "Show instance" (prop_matchesShow :: Int -> PkgName -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> PkgName -> Bool)+ describe "Pred" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Pred -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Pred -> Bool)+ describe "Pragma" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Pragma -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Pragma -> Bool)+ describe "Range" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Range -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Range -> Bool)+#if MIN_VERSION_template_haskell(2,9,0)+ describe "Role" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Role -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Role -> Bool)+#endif+#if MIN_VERSION_template_haskell(2,8,0)+ describe "RuleBndr" $ do+ prop "Show instance" (prop_matchesShow :: Int -> RuleBndr -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> RuleBndr -> Bool)+ describe "RuleMatch" $ do+ prop "Show instance" (prop_matchesShow :: Int -> RuleMatch -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> RuleMatch -> Bool)+#endif+ describe "Safety" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Safety -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Safety -> Bool)+ describe "Stmt" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Stmt -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Stmt -> Bool)+ describe "Strict" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Strict -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Strict -> Bool)+#if MIN_VERSION_template_haskell(2,8,0)+ describe "TyLit" $ do+ prop "Show instance" (prop_matchesShow :: Int -> TyLit -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> TyLit -> Bool)+#endif+ describe "Type" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Type -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> Type -> Bool)+#if MIN_VERSION_template_haskell(2,9,0)+ describe "TySynEqn" $ do+ prop "Show instance" (prop_matchesShow :: Int -> TySynEqn -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> TySynEqn -> Bool)+#endif+ describe "TyVarBndr" $ do+ prop "Show instance" (prop_matchesShow :: Int -> TyVarBndr -> Bool)+ prop "generic Show" (prop_genericShow :: Int -> TyVarBndr -> Bool)++-- | Verifies that `showName'` and `showbName'` have the same output.+prop_showName' :: NameIs -> Name -> Bool+prop_showName' nameIs name = fromString (showName' nameIs name) == showbName' nameIs name
tests/Spec/System/Console/HaskelineSpec.hs view
@@ -1,36 +1,41 @@-{-| -Module: Spec.System.Console.HaskelineSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @haskeline@ library. --} -module Spec.System.Console.HaskelineSpec (main, spec) where - -import Instances.System.Console.Haskeline () - -import Spec.Utils (prop_matchesShow) - -import System.Console.Haskeline (Interrupt, defaultPrefs) -import System.Console.Haskeline.Completion (Completion) -import System.Console.Haskeline.History (History) - -import Test.Hspec (Spec, describe, hspec, it, parallel, shouldBe) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text (FromStringShow(..), showb) -import Text.Show.Text.System.Console.Haskeline () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.System.Console.Haskeline" $ do - prop "Interrupt instance" (prop_matchesShow :: Int -> Interrupt -> Bool) --- prop "Prefs instance" (prop_matchesShow :: Int -> Prefs -> Bool) - it "defaultPrefs Show output" $ showb (FromStringShow defaultPrefs) `shouldBe` showb defaultPrefs - prop "Completion instance" (prop_matchesShow :: Int -> Completion -> Bool) - prop "History instance" (prop_matchesShow :: Int -> History -> Bool) +{-|+Module: Spec.System.Console.HaskelineSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @haskeline@ library.+-}+module Spec.System.Console.HaskelineSpec (main, spec) where++import Instances.System.Console.Haskeline ()++import Spec.Utils (prop_matchesShow)++import System.Console.Haskeline (Interrupt, defaultPrefs)+import System.Console.Haskeline.Completion (Completion)+import System.Console.Haskeline.History (History)++import Test.Hspec (Spec, describe, hspec, it, parallel, shouldBe)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text (FromStringShow(..), showb)+import Text.Show.Text.System.Console.Haskeline ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Interrupt" $+ prop "Show instance" (prop_matchesShow :: Int -> Interrupt -> Bool)+-- describe "Prefs" $+-- prop "Show instance" (prop_matchesShow :: Int -> Prefs -> Bool)+ describe "defaultPrefs" $+ it "should have coinciding string and text Show output" $ showb (FromStringShow defaultPrefs) `shouldBe` showb defaultPrefs+ describe "Completion" $+ prop "Show instance" (prop_matchesShow :: Int -> Completion -> Bool)+ describe "History" $+ prop "Show instance" (prop_matchesShow :: Int -> History -> Bool)
tests/Spec/System/Console/TerminfoSpec.hs view
@@ -1,43 +1,44 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.System.Console.TerminfoSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @terminfo@ library. --} -module Spec.System.Console.TerminfoSpec (main, spec) where - -import Prelude () -import Prelude.Compat - -import Test.Hspec (Spec, hspec, parallel) - -#if !defined(mingw32_HOST_OS) -import Instances.System.Console.Terminfo () - -import Spec.Utils (prop_matchesShow) - -import System.Console.Terminfo.Color (Color) - -import Test.Hspec (describe) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Console.Terminfo () -#endif - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel $ -#if !defined(mingw32_HOST_OS) - describe "Text.Show.Text.System.Console.Terminfo" $ do - prop "Color instance" (prop_matchesShow :: Int -> Color -> Bool) --- prop "SetupTermError instance" (prop_matchesShow :: Int -> SetupTermError -> Bool) -#else - pure () -#endif +{-# LANGUAGE CPP #-}+{-|+Module: Spec.System.Console.TerminfoSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @terminfo@ library.+-}+module Spec.System.Console.TerminfoSpec (main, spec) where++import Prelude ()+import Prelude.Compat++import Test.Hspec (Spec, hspec, parallel)++#if !defined(mingw32_HOST_OS)+import Instances.System.Console.Terminfo ()++import Spec.Utils (prop_matchesShow)++import System.Console.Terminfo.Color (Color)++import Test.Hspec (describe)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Console.Terminfo ()+#endif++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+#if !defined(mingw32_HOST_OS)+ describe "Color" $+ prop "Show instance" (prop_matchesShow :: Int -> Color -> Bool)+-- describe "SetupTermError" $+-- prop "Show instance" (prop_matchesShow :: Int -> SetupTermError -> Bool)+#else+ pure ()+#endif
tests/Spec/System/DirectorySpec.hs view
@@ -1,42 +1,42 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.System.DirectorySpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'Permissions'. --} -module Spec.System.DirectorySpec (main, spec) where - -import Prelude () -import Prelude.Compat - -import Test.Hspec (Spec, hspec, parallel) - -#if MIN_VERSION_directory(1,1,0) -import Instances.System.Directory () - -import Spec.Utils (prop_matchesShow) - -import System.Directory (Permissions) - -import Test.Hspec (describe) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Directory () -#endif - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel $ -#if MIN_VERSION_directory(1,1,0) - describe "Text.Show.Text.System.Directory" $ - prop "Permissions instance" (prop_matchesShow :: Int -> Permissions -> Bool) -#else - pure () -#endif +{-# LANGUAGE CPP #-}+{-|+Module: Spec.System.DirectorySpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for 'Permissions'.+-}+module Spec.System.DirectorySpec (main, spec) where++import Prelude ()+import Prelude.Compat++import Test.Hspec (Spec, hspec, parallel)++#if MIN_VERSION_directory(1,1,0)+import Instances.System.Directory ()++import Spec.Utils (prop_matchesShow)++import System.Directory (Permissions)++import Test.Hspec (describe)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Directory ()+#endif++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $+#if MIN_VERSION_directory(1,1,0)+ describe "Permissions" $+ prop "Show instance" (prop_matchesShow :: Int -> Permissions -> Bool)+#else+ pure ()+#endif
tests/Spec/System/LocaleSpec.hs view
@@ -1,29 +1,29 @@-{-| -Module: Spec.System.LocaleSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for old 'TimeLocale's. --} -module Spec.System.LocaleSpec (main, spec) where - -import Instances.System.Locale () - -import Spec.Utils (prop_matchesShow) - -import System.Locale (TimeLocale) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Locale () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.System.Locale" $ - prop "TimeLocale instance" (prop_matchesShow :: Int -> TimeLocale -> Bool) +{-|+Module: Spec.System.LocaleSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for old 'TimeLocale's.+-}+module Spec.System.LocaleSpec (main, spec) where++import Instances.System.Locale ()++import Spec.Utils (prop_matchesShow)++import System.Locale (TimeLocale)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Locale ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel . describe "TimeLocale" $+ prop "Show instance" (prop_matchesShow :: Int -> TimeLocale -> Bool)
tests/Spec/System/PosixSpec.hs view
@@ -1,48 +1,52 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.System.PosixSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @unix@ library. --} -module Spec.System.PosixSpec (main, spec) where - -import Prelude () -import Prelude.Compat - -import Test.Hspec (Spec, hspec, parallel) - -#if !defined(mingw32_HOST_OS) -import Instances.System.Posix () - -import Spec.Utils (prop_matchesShow) - -import System.Posix.DynamicLinker (RTLDFlags, DL) -import System.Posix.Process (ProcessStatus) -import System.Posix.User (GroupEntry, UserEntry) - -import Test.Hspec (describe) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Posix () -#endif - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel $ -#if !defined(mingw32_HOST_OS) - describe "Text.Show.Text.System.Posix" $ do - prop "RTLDFlags instance" (prop_matchesShow :: Int -> RTLDFlags -> Bool) - prop "DL instance" (prop_matchesShow :: Int -> DL -> Bool) - prop "ProcessStatus instance" (prop_matchesShow :: Int -> ProcessStatus -> Bool) - prop "GroupEntry instance" (prop_matchesShow :: Int -> GroupEntry -> Bool) - prop "UserEntry instance" (prop_matchesShow :: Int -> UserEntry -> Bool) -#else - pure () -#endif +{-# LANGUAGE CPP #-}+{-|+Module: Spec.System.PosixSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @unix@ library.+-}+module Spec.System.PosixSpec (main, spec) where++import Prelude ()+import Prelude.Compat++import Test.Hspec (Spec, hspec, parallel)++#if !defined(mingw32_HOST_OS)+import Instances.System.Posix ()++import Spec.Utils (prop_matchesShow)++import System.Posix.DynamicLinker (RTLDFlags, DL)+import System.Posix.Process (ProcessStatus)+import System.Posix.User (GroupEntry, UserEntry)++import Test.Hspec (describe)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Posix ()+#endif++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+#if !defined(mingw32_HOST_OS)+ describe "RTLDFlags" $+ prop "Show instance" (prop_matchesShow :: Int -> RTLDFlags -> Bool)+ describe "DL" $+ prop "Show instance" (prop_matchesShow :: Int -> DL -> Bool)+ describe "ProcessStatus" $+ prop "Show instance" (prop_matchesShow :: Int -> ProcessStatus -> Bool)+ describe "GroupEntry" $+ prop "Show instance" (prop_matchesShow :: Int -> GroupEntry -> Bool)+ describe "UserEntry" $+ prop "Show instance" (prop_matchesShow :: Int -> UserEntry -> Bool)+#else+ pure ()+#endif
tests/Spec/System/RandomSpec.hs view
@@ -1,29 +1,29 @@-{-| -Module: Spec.System.RandomSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for 'StdGen' values. --} -module Spec.System.RandomSpec (main, spec) where - -import Instances.System.Random () - -import Spec.Utils (prop_matchesShow) - -import System.Random (StdGen) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Random () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.System.Random" $ - prop "StdGen instance" (prop_matchesShow :: Int -> StdGen -> Bool) +{-|+Module: Spec.System.RandomSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for 'StdGen' values.+-}+module Spec.System.RandomSpec (main, spec) where++import Instances.System.Random ()++import Spec.Utils (prop_matchesShow)++import System.Random (StdGen)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Random ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel . describe "StdGen" $+ prop "Show instance" (prop_matchesShow :: Int -> StdGen -> Bool)
tests/Spec/System/TimeSpec.hs view
@@ -1,32 +1,37 @@-{-| -Module: Spec.System.TimeSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@QuickCheck@ properties for data types in @old-time@. --} -module Spec.System.TimeSpec (main, spec) where - -import Spec.Utils (prop_matchesShow) - -import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck.Instances () - -import Text.Show.Text.System.Time () - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.System.Time" $ do - prop "ClockTime instance" (prop_matchesShow :: Int -> ClockTime -> Bool) - prop "TimeDiff instance" (prop_matchesShow :: Int -> TimeDiff -> Bool) - prop "CalendarTime instance" (prop_matchesShow :: Int -> CalendarTime -> Bool) - prop "Month instance" (prop_matchesShow :: Int -> Month -> Bool) - prop "Day instance" (prop_matchesShow :: Int -> Day -> Bool) +{-|+Module: Spec.System.TimeSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@QuickCheck@ properties for data types in @old-time@.+-}+module Spec.System.TimeSpec (main, spec) where++import Spec.Utils (prop_matchesShow)++import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)+import Test.QuickCheck.Instances ()++import Text.Show.Text.System.Time ()++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "ClockTime" $+ prop "Show instance" (prop_matchesShow :: Int -> ClockTime -> Bool)+ describe "TimeDiff" $+ prop "Show instance" (prop_matchesShow :: Int -> TimeDiff -> Bool)+ describe "CalendarTime" $+ prop "Show instance" (prop_matchesShow :: Int -> CalendarTime -> Bool)+ describe "Month" $+ prop "Show instance" (prop_matchesShow :: Int -> Month -> Bool)+ describe "Day" $+ prop "Show instance" (prop_matchesShow :: Int -> Day -> Bool)
tests/Spec/System/Win32Spec.hs view
@@ -1,54 +1,63 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.System.Win32Spec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @Win32@ library. --} -module Spec.System.Win32Spec (main, spec) where - -import Prelude () -import Prelude.Compat - -import Test.Hspec (Spec, hspec, parallel) - -#if defined(mingw32_HOST_OS) -import Instances.System.Win32 () - -import Spec.Utils (prop_matchesShow) - -import System.Win32.DebugApi (DebugEventInfo, Exception) -import System.Win32.File (BY_HANDLE_FILE_INFORMATION, WIN32_FILE_ATTRIBUTE_DATA) -import System.Win32.Info (ProcessorArchitecture, SYSTEM_INFO) -import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId) - -import Test.Hspec (describe) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.System.Win32 () -#endif - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel $ -#if defined(mingw32_HOST_OS) - describe "Text.Show.Text.System.Win32" $ do - prop "DebugEventInfo instance" (prop_matchesShow :: Int -> DebugEventInfo -> Bool) - prop "Exception instance" (prop_matchesShow :: Int -> Exception -> Bool) - prop "BY_HANDLE_FILE_INFORMATION instance" (prop_matchesShow :: Int -> BY_HANDLE_FILE_INFORMATION -> Bool) - prop "WIN32_FILE_ATTRIBUTE_DATA instance" (prop_matchesShow :: Int -> WIN32_FILE_ATTRIBUTE_DATA -> Bool) - prop "ProcessorArchitecture instance" (prop_matchesShow :: Int -> ProcessorArchitecture -> Bool) - prop "SYSTEM_INFO instance" (prop_matchesShow :: Int -> SYSTEM_INFO -> Bool) - prop "FILETIME instance" (prop_matchesShow :: Int -> FILETIME -> Bool) - prop "SYSTEMTIME instance" (prop_matchesShow :: Int -> SYSTEMTIME -> Bool) - prop "TIME_ZONE_INFORMATION instance" (prop_matchesShow :: Int -> TIME_ZONE_INFORMATION -> Bool) - prop "TimeZoneId instance" (prop_matchesShow :: Int -> TimeZoneId -> Bool) -#else - pure () -#endif +{-# LANGUAGE CPP #-}+{-|+Module: Spec.System.Win32Spec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @Win32@ library.+-}+module Spec.System.Win32Spec (main, spec) where++import Prelude ()+import Prelude.Compat++import Test.Hspec (Spec, hspec, parallel)++#if defined(mingw32_HOST_OS)+import Instances.System.Win32 ()++import Spec.Utils (prop_matchesShow)++import System.Win32.DebugApi (DebugEventInfo, Exception)+import System.Win32.File (BY_HANDLE_FILE_INFORMATION, WIN32_FILE_ATTRIBUTE_DATA)+import System.Win32.Info (ProcessorArchitecture, SYSTEM_INFO)+import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId)++import Test.Hspec (describe)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.System.Win32 ()+#endif++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+#if defined(mingw32_HOST_OS)+ describe "DebugEventInfo" $+ prop "Show instance" (prop_matchesShow :: Int -> DebugEventInfo -> Bool)+ describe "Exception" $+ prop "Show instance" (prop_matchesShow :: Int -> Exception -> Bool)+ describe "BY_HANDLE_FILE_INFORMATION" $+ prop "Show instance" (prop_matchesShow :: Int -> BY_HANDLE_FILE_INFORMATION -> Bool)+ describe "WIN32_FILE_ATTRIBUTE_DATA" $+ prop "Show instance" (prop_matchesShow :: Int -> WIN32_FILE_ATTRIBUTE_DATA -> Bool)+ describe "ProcessorArchitecture" $+ prop "Show instance" (prop_matchesShow :: Int -> ProcessorArchitecture -> Bool)+ describe "SYSTEM_INFO" $+ prop "Show instance" (prop_matchesShow :: Int -> SYSTEM_INFO -> Bool)+ describe "FILETIME" $+ prop "Show instance" (prop_matchesShow :: Int -> FILETIME -> Bool)+ describe "SYSTEMTIME" $+ prop "Show instance" (prop_matchesShow :: Int -> SYSTEMTIME -> Bool)+ describe "TIME_ZONE_INFORMATION" $+ prop "Show instance" (prop_matchesShow :: Int -> TIME_ZONE_INFORMATION -> Bool)+ describe "TimeZoneId" $+ prop "Show instance" (prop_matchesShow :: Int -> TimeZoneId -> Bool)+#else+ pure ()+#endif
tests/Spec/Text/PrettyPrintSpec.hs view
@@ -1,45 +1,63 @@-{-# LANGUAGE CPP #-} -{-| -Module: Spec.Text.PrettyPrintSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @pretty@ library. --} -module Spec.Text.PrettyPrintSpec (main, spec) where - -import Instances.Text.PrettyPrint () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails {-, renderStyle -}) -#if MIN_VERSION_pretty(1,1,2) -import Text.PrettyPrint.HughesPJClass (PrettyLevel) -#endif --- import Text.Show.Text (fromString) -import Text.Show.Text.Text.PrettyPrint () -- (renderStyleB) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Text.PrettyPrint" $ do - prop "Doc instance" (prop_matchesShow :: Int -> Doc -> Bool) - -- TODO: Figure out why this randomly stalls forever --- prop "renderStyleB output" prop_renderStyle - prop "Mode instance" (prop_matchesShow :: Int -> Mode -> Bool) - prop "Style instance" (prop_matchesShow :: Int -> Style -> Bool) - prop "TextDetails instance" (prop_matchesShow :: Int -> TextDetails -> Bool) -#if MIN_VERSION_pretty(1,1,2) - prop "PrettyLevel instance" (prop_matchesShow :: Int -> PrettyLevel -> Bool) -#endif - --- | Verifies that the output of 'renderStyle' and 'renderStyleB' coincides. --- prop_renderStyle :: Style -> Doc -> Bool --- prop_renderStyle sty doc = fromString (renderStyle sty doc) == renderStyleB sty doc +{-# LANGUAGE CPP #-}+{-|+Module: Spec.Text.PrettyPrintSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @pretty@ library.+-}+module Spec.Text.PrettyPrintSpec (main, spec) where++import Instances.Text.PrettyPrint ()++import Spec.Utils (prop_matchesShow)+#if MIN_VERSION_pretty(1,1,2)+import Spec.Utils (prop_genericShow)+#endif++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails {-, renderStyle -})+#if MIN_VERSION_pretty(1,1,2)+import Text.PrettyPrint.HughesPJClass (PrettyLevel)+#endif+-- import Text.Show.Text (fromString)+import Text.Show.Text.Text.PrettyPrint () -- (renderStyleB)++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Doc" $+ prop "Show instance" (prop_matchesShow :: Int -> Doc -> Bool)+ -- TODO: Figure out why this randomly stalls forever+-- describe "renderStyleB" $ do+-- prop "has the same output as renderStyle" prop_renderStyle+ describe "Mode" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Mode -> Bool)+#if MIN_VERSION_pretty(1,1,2)+ prop "generic Show" (prop_genericShow :: Int -> Mode -> Bool)+#endif+ describe "Style" $ do+ prop "Show instance" (prop_matchesShow :: Int -> Style -> Bool)+#if MIN_VERSION_pretty(1,1,2)+ prop "generic Show" (prop_genericShow :: Int -> Style -> Bool)+#endif+ describe "TextDetails" $ do+ prop "Show instance" (prop_matchesShow :: Int -> TextDetails -> Bool)+#if MIN_VERSION_pretty(1,1,2)+ prop "generic Show" (prop_genericShow :: Int -> TextDetails -> Bool)+#endif+#if MIN_VERSION_pretty(1,1,2)+ describe "PrettyLevel" $+ prop "Show instance" (prop_matchesShow :: Int -> PrettyLevel -> Bool)+#endif++-- | Verifies that the output of 'renderStyle' and 'renderStyleB' coincides.+-- prop_renderStyle :: Style -> Doc -> Bool+-- prop_renderStyle sty doc = fromString (renderStyle sty doc) == renderStyleB sty doc
tests/Spec/Text/XHtmlSpec.hs view
@@ -1,33 +1,38 @@-{-| -Module: Spec.Text.XHtmlSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @xhtml@ library. --} -module Spec.Text.XHtmlSpec (main, spec) where - -import Instances.Text.XHtml () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Text.XHtml () -import Text.XHtml.Frameset (Html, HtmlAttr, HotLink) -import Text.XHtml.Table (HtmlTable) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Text.XHtml" $ do - prop "Html instance" (prop_matchesShow :: Int -> Html -> Bool) - prop "[Html] instance" (prop_matchesShow :: Int -> [Html] -> Bool) - prop "HtmlAttr instance" (prop_matchesShow :: Int -> HtmlAttr -> Bool) - prop "HotLink instance" (prop_matchesShow :: Int -> HotLink -> Bool) - prop "HtmlTable instance" (prop_matchesShow :: Int -> HtmlTable -> Bool) +{-|+Module: Spec.Text.XHtmlSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @xhtml@ library.+-}+module Spec.Text.XHtmlSpec (main, spec) where++import Instances.Text.XHtml ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Text.XHtml ()+import Text.XHtml.Frameset (Html, HtmlAttr, HotLink)+import Text.XHtml.Table (HtmlTable)++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Html" $+ prop "Show instance" (prop_matchesShow :: Int -> Html -> Bool)+ describe "[Html]" $+ prop "Show instance" (prop_matchesShow :: Int -> [Html] -> Bool)+ describe "HtmlAttr" $+ prop "Show instance" (prop_matchesShow :: Int -> HtmlAttr -> Bool)+ describe "HotLink" $+ prop "Show instance" (prop_matchesShow :: Int -> HotLink -> Bool)+ describe "HtmlTable" $+ prop "Show instance" (prop_matchesShow :: Int -> HtmlTable -> Bool)
tests/Spec/Trace/HpcSpec.hs view
@@ -1,37 +1,44 @@-{-| -Module: Spec.Trace.HpcSpec -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@hspec@ tests for data types in the @hpc@ library. --} -module Spec.Trace.HpcSpec (main, spec) where - -import Instances.Trace.Hpc () - -import Spec.Utils (prop_matchesShow) - -import Test.Hspec (Spec, describe, hspec, parallel) -import Test.Hspec.QuickCheck (prop) - -import Text.Show.Text.Trace.Hpc () - -import Trace.Hpc.Mix (Mix, BoxLabel, CondBox) -import Trace.Hpc.Tix (Tix, TixModule) -import Trace.Hpc.Util (HpcPos, Hash) - -main :: IO () -main = hspec spec - -spec :: Spec -spec = parallel . describe "Text.Show.Text.Trace.Hpc" $ do - prop "Mix instance" (prop_matchesShow :: Int -> Mix -> Bool) - prop "BoxLabel instance" (prop_matchesShow :: Int -> BoxLabel -> Bool) - prop "CondBox instance" (prop_matchesShow :: Int -> CondBox -> Bool) - prop "Tix instance" (prop_matchesShow :: Int -> Tix -> Bool) - prop "TixModule instance" (prop_matchesShow :: Int -> TixModule -> Bool) - prop "HpcPos instance" (prop_matchesShow :: Int -> HpcPos -> Bool) - prop "Hash instance" (prop_matchesShow :: Int -> Hash -> Bool) +{-|+Module: Spec.Trace.HpcSpec+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@hspec@ tests for data types in the @hpc@ library.+-}+module Spec.Trace.HpcSpec (main, spec) where++import Instances.Trace.Hpc ()++import Spec.Utils (prop_matchesShow)++import Test.Hspec (Spec, describe, hspec, parallel)+import Test.Hspec.QuickCheck (prop)++import Text.Show.Text.Trace.Hpc ()++import Trace.Hpc.Mix (Mix, BoxLabel, CondBox)+import Trace.Hpc.Tix (Tix, TixModule)+import Trace.Hpc.Util (HpcPos, Hash)++main :: IO ()+main = hspec spec++spec :: Spec+spec = parallel $ do+ describe "Mix" $+ prop "Show instance" (prop_matchesShow :: Int -> Mix -> Bool)+ describe "BoxLabel" $+ prop "Show instance" (prop_matchesShow :: Int -> BoxLabel -> Bool)+ describe "CondBox" $+ prop "Show instance" (prop_matchesShow :: Int -> CondBox -> Bool)+ describe "Tix" $+ prop "Show instance" (prop_matchesShow :: Int -> Tix -> Bool)+ describe "TixModule" $+ prop "Show instance" (prop_matchesShow :: Int -> TixModule -> Bool)+ describe "HpcPos" $+ prop "Show instance" (prop_matchesShow :: Int -> HpcPos -> Bool)+ describe "Hash" $+ prop "Show instance" (prop_matchesShow :: Int -> Hash -> Bool)
tests/Spec/Utils.hs view
@@ -1,22 +1,62 @@-{-| -Module: Spec.Utils -Copyright: (C) 2014-2015 Ryan Scott -License: BSD-style (see the file LICENSE) -Maintainer: Ryan Scott -Stability: Experimental -Portability: GHC - -@QuickCheck@ property-related utility functions. --} -module Spec.Utils (prop_matchesShow) where - -import Prelude hiding (Show) - -import qualified Text.Show as S (Show) -import qualified Text.Show.Text as T (Show) -import Text.Show.Text (showbPrec, FromStringShow(..)) - --- | Verifies that a type's @Show@ instances coincide for both 'String's and 'Text', --- irrespective of precedence. -prop_matchesShow :: (S.Show a, T.Show a) => Int -> a -> Bool -prop_matchesShow p x = showbPrec p (FromStringShow x) == showbPrec p x +{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}++{-|+Module: Spec.Utils+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Provisional+Portability: GHC++@QuickCheck@ property-related utility functions.+-}+module Spec.Utils (prop_matchesShow, prop_genericShow, prop_genericShow1) where++#if __GLASGOW_HASKELL__ >= 704+import GHC.Generics (Generic, Rep)+# if __GLASGOW_HASKELL__ >= 706+import GHC.Generics (Generic1, Rep1)+# endif+import Text.Show.Text.Generic+#endif++import Prelude hiding (Show)++import qualified Text.Show as S (Show)+import Text.Show.Text as T++-- | Verifies that a type's @Show@ instances coincide for both 'String's and 'Text',+-- irrespective of precedence.+prop_matchesShow :: (S.Show a, T.Show a) => Int -> a -> Bool+prop_matchesShow p x = showbPrec p (FromStringShow x) == showbPrec p x++-- | Verifies that a type's @Show@ instance coincides with the output produced+-- by the equivalent 'Generic' functions.+#if __GLASGOW_HASKELL__ >= 704+prop_genericShow :: (T.Show a, Generic a, GShow (Rep a))+ => Int -> a -> Bool+prop_genericShow p x = showbPrec p x == genericShowbPrec p x+#else+prop_genericShow :: Int -> a -> Bool+prop_genericShow _ _ = True+#endif++-- | Verifies that a type's @Show1@ instance coincides with the output produced+-- by the equivalent 'Generic1' functions.+#if __GLASGOW_HASKELL__ >= 706+prop_genericShow1 :: (T.Show1 f, Generic1 f, GShow1 (Rep1 f))+ => Int -> f a -> Bool+prop_genericShow1 p x = showbPrecWith showb27Prec p x+ == genericShowbPrecWith showb27Prec p x+#else+prop_genericShow1 :: Int -> f a -> Bool+prop_genericShow1 _ _ = True+#endif++#if __GLASGOW_HASKELL__ >= 706+-- | Show the number 27, which certain parody singer-songwriters find humorous.+-- Useful for testing higher-order @Show@ classes.+showb27Prec :: Int -> a -> Builder+showb27Prec p _ = showbPrec p $ Just (27 :: Int)+#endif
text-show-instances.cabal view
@@ -1,243 +1,245 @@-name: text-show-instances -version: 0.4 -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 - common Haskell libraries and GHC dependencies that are not - encompassed by @text-show@. Currently, @text-show-instances@ - covers these libraries: - . - * @<http://hackage.haskell.org/package/binary binary>@ - . - * @<http://hackage.haskell.org/package/containers containers>@ - . - * @<http://hackage.haskell.org/package/directory directory>@ - . - * @<http://hackage.haskell.org/package/haskeline haskeline>@ - . - * @<http://hackage.haskell.org/package/hoopl hoopl>@ - . - * @<http://hackage.haskell.org/package/hpc hpc>@ - . - * @<http://hackage.haskell.org/package/old-locale old-locale>@ - . - * @<http://hackage.haskell.org/package/old-time old-time>@ - . - * @<http://hackage.haskell.org/package/pretty pretty>@ - . - * @<http://hackage.haskell.org/package/random random>@ - . - * @<http://hackage.haskell.org/package/semigroups semigroups>@ - . - * @<http://hackage.haskell.org/package/tagged tagged>@ - . - * @<http://hackage.haskell.org/package/template-haskell template-haskell>@ - . - * @<http://hackage.haskell.org/package/terminfo terminfo>@ - . - * @<http://hackage.haskell.org/package/time time>@ - . - * @<http://hackage.haskell.org/package/transformers transformers>@ - . - * @<http://hackage.haskell.org/package/unix unix>@ - . - * @<http://hackage.haskell.org/package/unordered-containers unordered-containers>@ - . - * @<http://hackage.haskell.org/package/utf8-string utf8-string>@ - . - * @<http://hackage.haskell.org/package/vector vector>@ - . - * @<http://hackage.haskell.org/package/Win32 Win32>@ - . - * @<http://hackage.haskell.org/package/xhtml xhtml>@ - . - One can use these instances by importing - "Text.Show.Text.Instances". Alternatively, there are monomorphic - versions of the @showb@ function available in the other submodules - of "Text.Show.Text". -homepage: https://github.com/RyanGlScott/text-show-instances -bug-reports: https://github.com/RyanGlScott/text-show-instances/issues -license: BSD3 -license-file: LICENSE -author: Ryan Scott -maintainer: Ryan Scott <ryan.gl.scott@ku.edu> -stability: Experimental -copyright: (C) 2014-2015 Ryan Scott -category: Text -build-type: Simple -tested-with: GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1 -extra-source-files: CHANGELOG.md, README.md, include/inline.h -cabal-version: >=1.10 - -source-repository head - type: git - location: https://github.com/RyanGlScott/text-show-instances - -library - exposed-modules: Text.Show.Text.Instances - - Text.Show.Text.Compiler.Hoopl - Text.Show.Text.Control.Applicative.Trans - Text.Show.Text.Control.Monad.Trans - Text.Show.Text.Data.Binary - Text.Show.Text.Data.Containers - Text.Show.Text.Data.Functor.Trans - Text.Show.Text.Data.List.NonEmpty - Text.Show.Text.Data.Semigroup - Text.Show.Text.Data.String.UTF8 - Text.Show.Text.Data.Tagged - Text.Show.Text.Data.Time - Text.Show.Text.Data.UnorderedContainers - Text.Show.Text.Data.Vector - Text.Show.Text.Language.Haskell.TH - Text.Show.Text.System.Console.Haskeline - Text.Show.Text.System.Directory - Text.Show.Text.System.Locale - Text.Show.Text.System.Random - Text.Show.Text.System.Time - Text.Show.Text.Text.PrettyPrint - Text.Show.Text.Text.XHtml - Text.Show.Text.Trace.Hpc - - -- Only exports functions if using Windows - Text.Show.Text.System.Win32 - - -- Only exports functions if not using Windows - Text.Show.Text.System.Console.Terminfo - Text.Show.Text.System.Posix - other-modules: Text.Show.Text.Utils - build-depends: base >= 4.3 && < 5 - , base-compat >= 0.8.1 && < 1 - , binary >= 0.6 && < 0.8 - , bytestring >= 0.9 && < 0.11 - , containers >= 0.1 && < 0.6 - , directory >= 1 && < 1.3 - , haskeline >= 0.7 && < 0.8 - , hoopl >= 3.8.7 && < 3.11 - , hpc >= 0.5 && < 0.7 - , old-locale >= 1 && < 1.1 - , old-time >= 1 && < 1.2 - , pretty >= 1 && < 1.2 - , random >= 1.0.1 && < 1.2 - , semigroups >= 0.16.2 && < 1 - , tagged >= 0.4.4 && < 1 - , template-haskell >= 2.5 && < 2.11 - , text >= 0.11.1 && < 1.3 - , text-show >= 0.5 && < 0.9 - , time >= 0.1 && < 1.6 - , transformers >= 0.2.1 && < 0.5 - , transformers-compat >= 0.3 && < 1 - , unordered-containers >= 0.2 && < 0.3 - , utf8-string >= 0.3.1 && < 1.1 - , vector >= 0.9 && < 0.11 - , xhtml >= 3000.2 && < 3000.3 - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall - include-dirs: include - includes: inline.h - install-includes: inline.h - - if os(windows) - build-depends: Win32 >= 2.1 && < 2.4 - else - build-depends: terminfo >= 0.3.2 && < 0.5 - , unix >= 2 && < 2.8 - -test-suite text-show-instances-spec - type: exitcode-stdio-1.0 - main-is: Spec.hs - other-modules: Instances.Compiler.Hoopl - Instances.Control.Applicative.Trans - Instances.Control.Monad.Trans - Instances.Data.Binary - Instances.Data.Containers - Instances.Data.Functor.Trans - Instances.Data.List.NonEmpty - Instances.Data.Semigroup - Instances.Data.String.UTF8 - Instances.Data.Tagged - Instances.Language.Haskell.TH - Instances.Miscellaneous - Instances.System.Console.Haskeline - Instances.System.Directory - Instances.System.Locale - Instances.System.Random - Instances.Text.PrettyPrint - Instances.Text.XHtml - Instances.Trace.Hpc - Instances.Utils - - -- Only exports functions if using Windows - Instances.System.Win32 - - -- Only exports functions if not using Windows - Instances.System.Console.Terminfo - Instances.System.Posix - - Spec.Compiler.HooplSpec - Spec.Control.Applicative.TransSpec - Spec.Control.Monad.TransSpec - Spec.Data.BinarySpec - Spec.Data.ContainersSpec - Spec.Data.Functor.TransSpec - Spec.Data.List.NonEmptySpec - Spec.Data.SemigroupSpec - Spec.Data.String.UTF8Spec - Spec.Data.TaggedSpec - Spec.Data.TimeSpec - Spec.Data.UnorderedContainersSpec - Spec.Language.Haskell.THSpec - Spec.System.Console.HaskelineSpec - Spec.System.DirectorySpec - Spec.System.LocaleSpec - Spec.System.RandomSpec - Spec.System.TimeSpec - Spec.Text.PrettyPrintSpec - Spec.Text.XHtmlSpec - Spec.Trace.HpcSpec - Spec.Utils - - -- Only exports functions if using Windows - Spec.System.Win32Spec - - -- Only exports functions if not using Windows - Spec.System.Console.TerminfoSpec - Spec.System.PosixSpec - build-depends: base >= 4.3 && < 5 - , base-compat >= 0.8.1 && < 1 - , binary >= 0.6 && < 0.8 - , bytestring >= 0.9 && < 0.11 - , containers >= 0.1 && < 0.6 - , directory >= 1 && < 1.3 - , haskeline >= 0.7 && < 0.8 - , hoopl >= 3.8.7 && < 3.11 - , hpc >= 0.5 && < 0.7 - , hspec >= 2 && < 3 - , old-locale >= 1 && < 1.1 - , old-time >= 1 && < 1.2 - , pretty >= 1 && < 1.2 - , QuickCheck >= 2.5 && < 3 - , quickcheck-instances >= 0.1 && < 0.4 - , random >= 1.0.1 && < 1.2 - , semigroups >= 0.8.4 && < 1 - , tagged >= 0.4.4 && < 1 - , template-haskell >= 2.5 && < 2.11 - , text-show >= 0.5 && < 0.9 - , text-show-instances == 0.4 - , time >= 0.1 && < 1.6 - , transformers >= 0.2.1 && < 0.5 - , transformers-compat >= 0.3 && < 1 - , unordered-containers >= 0.2 && < 0.3 - , utf8-string >= 0.3.1 && < 1.1 - , vector >= 0.9 && < 0.11 - , xhtml >= 3000.2 && < 3000.3 - hs-source-dirs: tests - default-language: Haskell2010 - ghc-options: -Wall -threaded -rtsopts - - if os(windows) - build-depends: Win32 >= 2.1 && < 2.4 - else - build-depends: terminfo >= 0.3.2 && < 0.5 - , unix >= 2 && < 2.8 +name: text-show-instances+version: 1+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+ common Haskell libraries and GHC dependencies that are not+ encompassed by @text-show@. Currently, @text-show-instances@+ covers these libraries:+ .+ * @<http://hackage.haskell.org/package/bifunctors bifunctors>@+ .+ * @<http://hackage.haskell.org/package/binary binary>@+ .+ * @<http://hackage.haskell.org/package/containers containers>@+ .+ * @<http://hackage.haskell.org/package/directory directory>@+ .+ * @<http://hackage.haskell.org/package/haskeline haskeline>@+ .+ * @<http://hackage.haskell.org/package/hoopl hoopl>@+ .+ * @<http://hackage.haskell.org/package/hpc hpc>@+ .+ * @<http://hackage.haskell.org/package/old-locale old-locale>@+ .+ * @<http://hackage.haskell.org/package/old-time old-time>@+ .+ * @<http://hackage.haskell.org/package/pretty pretty>@+ .+ * @<http://hackage.haskell.org/package/random random>@+ .+ * @<http://hackage.haskell.org/package/semigroups semigroups>@+ .+ * @<http://hackage.haskell.org/package/tagged tagged>@+ .+ * @<http://hackage.haskell.org/package/template-haskell template-haskell>@+ .+ * @<http://hackage.haskell.org/package/terminfo terminfo>@+ .+ * @<http://hackage.haskell.org/package/time time>@+ .+ * @<http://hackage.haskell.org/package/transformers transformers>@+ .+ * @<http://hackage.haskell.org/package/unix unix>@+ .+ * @<http://hackage.haskell.org/package/unordered-containers unordered-containers>@+ .+ * @<http://hackage.haskell.org/package/vector vector>@+ .+ * @<http://hackage.haskell.org/package/Win32 Win32>@+ .+ * @<http://hackage.haskell.org/package/xhtml xhtml>@+ .+ One can use these instances by importing+ "Text.Show.Text.Instances". Alternatively, there are monomorphic+ versions of the @showb@ function available in the other submodules+ of "Text.Show.Text".+homepage: https://github.com/RyanGlScott/text-show-instances+bug-reports: https://github.com/RyanGlScott/text-show-instances/issues+license: BSD3+license-file: LICENSE+author: Ryan Scott+maintainer: Ryan Scott <ryan.gl.scott@ku.edu>+stability: Experimental+copyright: (C) 2014-2015 Ryan Scott+category: Text+build-type: Simple+tested-with: GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1+extra-source-files: CHANGELOG.md, README.md, include/inline.h+cabal-version: >=1.10++source-repository head+ type: git+ location: https://github.com/RyanGlScott/text-show-instances++library+ exposed-modules: Text.Show.Text.Instances++ Text.Show.Text.Compiler.Hoopl+ Text.Show.Text.Control.Applicative.Trans+ Text.Show.Text.Control.Monad.Trans+ Text.Show.Text.Data.Bifunctor+ Text.Show.Text.Data.Binary+ Text.Show.Text.Data.Containers+ Text.Show.Text.Data.Functor.Trans+ Text.Show.Text.Data.List.NonEmpty+ Text.Show.Text.Data.Semigroup+ Text.Show.Text.Data.Tagged+ Text.Show.Text.Data.Time+ Text.Show.Text.Data.UnorderedContainers+ Text.Show.Text.Data.Vector+ Text.Show.Text.Language.Haskell.TH+ Text.Show.Text.System.Console.Haskeline+ Text.Show.Text.System.Directory+ Text.Show.Text.System.Locale+ Text.Show.Text.System.Random+ Text.Show.Text.System.Time+ Text.Show.Text.Text.PrettyPrint+ Text.Show.Text.Text.XHtml+ Text.Show.Text.Trace.Hpc++ -- Only exports functions if using Windows+ Text.Show.Text.System.Win32++ -- Only exports functions if not using Windows+ Text.Show.Text.System.Console.Terminfo+ Text.Show.Text.System.Posix+ other-modules: Text.Show.Text.Utils+ build-depends: base >= 4.3 && < 5+ , base-compat >= 0.8.1 && < 1+ , bifunctors >= 5 && < 6+ , binary >= 0.6 && < 0.8+ , bytestring >= 0.9 && < 0.11+ , containers >= 0.1 && < 0.6+ , directory >= 1 && < 1.3+ , haskeline >= 0.7 && < 0.8+ , hoopl >= 3.8.7 && < 3.11+ , hpc >= 0.5 && < 0.7+ , old-locale >= 1 && < 1.1+ , old-time >= 1 && < 1.2+ , pretty >= 1 && < 1.2+ , random >= 1.0.1 && < 1.2+ , semigroups >= 0.16.2 && < 1+ , tagged >= 0.4.4 && < 1+ , template-haskell >= 2.5 && < 2.11+ , text >= 0.11.1 && < 1.3+ , text-show >= 1 && < 1.1+ , time >= 0.1 && < 1.6+ , transformers >= 0.2.1 && < 0.5+ , transformers-compat >= 0.3 && < 1+ , unordered-containers >= 0.2 && < 0.3+ , vector >= 0.9 && < 0.11+ , xhtml >= 3000.2 && < 3000.3+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall+ include-dirs: include+ includes: inline.h+ install-includes: inline.h++ if os(windows)+ build-depends: Win32 >= 2.1 && < 2.4+ else+ build-depends: terminfo >= 0.3.2 && < 0.5+ , unix >= 2 && < 2.8++test-suite text-show-instances-spec+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules: Instances.Compiler.Hoopl+ Instances.Control.Applicative.Trans+ Instances.Control.Monad.Trans+ Instances.Data.Bifunctor+ 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+ Instances.System.Console.Haskeline+ Instances.System.Directory+ Instances.System.Locale+ Instances.System.Random+ Instances.Text.PrettyPrint+ Instances.Text.XHtml+ Instances.Trace.Hpc+ Instances.Utils++ -- Only exports functions if using Windows+ Instances.System.Win32++ -- Only exports functions if not using Windows+ Instances.System.Console.Terminfo+ Instances.System.Posix++ Spec.Compiler.HooplSpec+ Spec.Control.Applicative.TransSpec+ Spec.Control.Monad.TransSpec+ Spec.Data.BifunctorSpec+ 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+ Spec.Language.Haskell.THSpec+ Spec.System.Console.HaskelineSpec+ Spec.System.DirectorySpec+ Spec.System.LocaleSpec+ Spec.System.RandomSpec+ Spec.System.TimeSpec+ Spec.Text.PrettyPrintSpec+ Spec.Text.XHtmlSpec+ Spec.Trace.HpcSpec+ Spec.Utils++ -- Only exports functions if using Windows+ Spec.System.Win32Spec++ -- Only exports functions if not using Windows+ Spec.System.Console.TerminfoSpec+ Spec.System.PosixSpec+ build-depends: base >= 4.3 && < 5+ , base-compat >= 0.8.1 && < 1+ , bifunctors >= 5 && < 6+ , binary >= 0.6 && < 0.8+ , bytestring >= 0.9 && < 0.11+ , containers >= 0.1 && < 0.6+ , directory >= 1 && < 1.3+ , ghc-prim+ , haskeline >= 0.7 && < 0.8+ , hoopl >= 3.8.7 && < 3.11+ , hpc >= 0.5 && < 0.7+ , hspec >= 2 && < 3+ , old-locale >= 1 && < 1.1+ , old-time >= 1 && < 1.2+ , pretty >= 1 && < 1.2+ , QuickCheck >= 2.5 && < 3+ , quickcheck-instances >= 0.1 && < 0.4+ , random >= 1.0.1 && < 1.2+ , semigroups >= 0.8.4 && < 1+ , tagged >= 0.4.4 && < 1+ , template-haskell >= 2.5 && < 2.11+ , text-show >= 1 && < 1.1+ , text-show-instances == 1+ , th-orphans >= 0.12 && < 1+ , time >= 0.1 && < 1.6+ , transformers >= 0.2.1 && < 0.5+ , transformers-compat >= 0.3 && < 1+ , unordered-containers >= 0.2 && < 0.3+ , vector >= 0.9 && < 0.11+ , xhtml >= 3000.2 && < 3000.3+ hs-source-dirs: tests+ default-language: Haskell2010+ ghc-options: -Wall -threaded -rtsopts++ if os(windows)+ build-depends: Win32 >= 2.1 && < 2.4+ else+ build-depends: terminfo >= 0.3.2 && < 0.5+ , unix >= 2 && < 2.8