text-show-instances 0.1.0.1 → 0.2
raw patch · 46 files changed
+1147/−233 lines, 46 filesdep +binarydep +bytestringdep +haskelinedep ~textdep ~text-showdep ~text-show-instancesPVP ok
version bump matches the API change (PVP)
Dependencies added: binary, bytestring, haskeline, hoopl, tasty-hunit, terminfo, utf8-string
Dependency ranges changed: text, text-show, text-show-instances, transformers
API changes (from Hackage documentation)
+ Text.Show.Text.Compiler.Hoopl: instance Show DPath
+ Text.Show.Text.Compiler.Hoopl: instance Show DominatorNode
+ Text.Show.Text.Compiler.Hoopl: instance Show DominatorTree
+ Text.Show.Text.Compiler.Hoopl: instance Show Label
+ Text.Show.Text.Compiler.Hoopl: instance Show LabelSet
+ Text.Show.Text.Compiler.Hoopl: instance Show UniqueSet
+ Text.Show.Text.Compiler.Hoopl: instance Show a => Show (Pointed t b a)
+ Text.Show.Text.Compiler.Hoopl: instance Show v0 => Show (LabelMap v0)
+ Text.Show.Text.Compiler.Hoopl: instance Show v0 => Show (UniqueMap v0)
+ Text.Show.Text.Compiler.Hoopl: instance Show1 (Pointed t b)
+ Text.Show.Text.Compiler.Hoopl: instance Show1 LabelMap
+ Text.Show.Text.Compiler.Hoopl: instance Show1 UniqueMap
+ Text.Show.Text.Compiler.Hoopl: showbDPath :: DPath -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbDominatorNode :: DominatorNode -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbDominatorTree :: DominatorTree -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbLabel :: Label -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbLabelMapPrec :: Show v => Int -> LabelMap v -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbLabelSetPrec :: Int -> LabelSet -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbPointed :: Show a => Pointed t b a -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbUnique :: Unique -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbUniqueMapPrec :: Show v => Int -> UniqueMap v -> Builder
+ Text.Show.Text.Compiler.Hoopl: showbUniqueSetPrec :: Int -> UniqueSet -> Builder
+ Text.Show.Text.Data.Binary: instance Show a => Show (Decoder a)
+ Text.Show.Text.Data.Binary: instance Show1 Decoder
+ Text.Show.Text.Data.Binary: showbDecoder :: Show a => Decoder a -> 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.Language.Haskell.TH: showbKindPrec :: Int -> Kind -> Builder
+ Text.Show.Text.System.Console.Haskeline: instance Show Completion
+ Text.Show.Text.System.Console.Haskeline: instance Show History
+ Text.Show.Text.System.Console.Haskeline: instance Show Interrupt
+ Text.Show.Text.System.Console.Haskeline: instance Show Prefs
+ Text.Show.Text.System.Console.Haskeline: showbCompletionPrec :: Int -> Completion -> Builder
+ Text.Show.Text.System.Console.Haskeline: showbHistory :: History -> Builder
+ Text.Show.Text.System.Console.Haskeline: showbInterrupt :: Interrupt -> Builder
+ Text.Show.Text.System.Console.Haskeline: showbPrefsPrec :: Int -> Prefs -> Builder
+ Text.Show.Text.System.Console.Terminfo: instance Show Color
+ Text.Show.Text.System.Console.Terminfo: instance Show SetupTermError
+ Text.Show.Text.System.Console.Terminfo: showbColorPrec :: Int -> Color -> Builder
+ Text.Show.Text.System.Console.Terminfo: showbSetupTermError :: SetupTermError -> Builder
+ Text.Show.Text.Text.PrettyPrint: renderStyleB :: Style -> Doc -> Builder
Files
- CHANGELOG.md +7/−0
- README.md +7/−2
- src/Text/Show/Text/Compiler.hs +13/−0
- src/Text/Show/Text/Compiler/Hoopl.hs +194/−0
- src/Text/Show/Text/Data.hs +2/−0
- src/Text/Show/Text/Data/Binary.hs +41/−0
- src/Text/Show/Text/Data/String/UTF8.hs +63/−0
- src/Text/Show/Text/Data/Time.hs +31/−6
- src/Text/Show/Text/Data/Vector.hs +2/−2
- src/Text/Show/Text/Instances.hs +1/−0
- src/Text/Show/Text/Language/Haskell/TH.hs +65/−71
- src/Text/Show/Text/System.hs +7/−5
- src/Text/Show/Text/System/Console/Haskeline.hs +71/−0
- src/Text/Show/Text/System/Console/Terminfo.hs +45/−0
- src/Text/Show/Text/System/Directory.hs +2/−2
- src/Text/Show/Text/System/Locale.hs +3/−3
- src/Text/Show/Text/System/Posix.hs +6/−6
- src/Text/Show/Text/System/Time.hs +5/−6
- src/Text/Show/Text/System/Win32.hs +10/−9
- src/Text/Show/Text/Text/PrettyPrint.hs +20/−7
- src/Text/Show/Text/Text/XHtml.hs +2/−2
- src/Text/Show/Text/Trace/Hpc.hs +5/−4
- tests/Instances/Compiler/Hoopl.hs +72/−0
- tests/Instances/Data/Binary.hs +30/−0
- tests/Instances/Data/String/UTF8.hs +20/−0
- tests/Instances/Language/Haskell/TH.hs +47/−48
- tests/Instances/Miscellaneous.hs +5/−0
- tests/Instances/System/Console/Haskeline.hs +38/−0
- tests/Instances/System/Console/Terminfo.hs +34/−0
- tests/Instances/System/Locale.hs +1/−1
- tests/Instances/System/Posix.hs +5/−3
- tests/Instances/System/Win32.hs +4/−2
- tests/Instances/Text/PrettyPrint.hs +8/−3
- tests/Instances/Trace/Hpc.hs +10/−6
- tests/Instances/Utils.hs +16/−0
- tests/Properties.hs +14/−4
- tests/Properties/Compiler/Hoopl.hs +40/−0
- tests/Properties/Data/Binary.hs +29/−0
- tests/Properties/Data/String/UTF8.hs +35/−0
- tests/Properties/Language/Haskell/TH.hs +0/−4
- tests/Properties/System/Console/Haskeline.hs +37/−0
- tests/Properties/System/Console/Terminfo.hs +30/−0
- tests/Properties/System/Directory.hs +1/−3
- tests/Properties/System/Locale.hs +1/−1
- tests/Properties/Text/PrettyPrint.hs +10/−4
- text-show-instances.cabal +58/−29
CHANGELOG.md view
@@ -1,2 +1,9 @@+# 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
README.md view
@@ -1,9 +1,12 @@-# `text-show-instances` [](http://hackage.haskell.org/package/text-show-instances) [](https://travis-ci.org/RyanGlScott/text-show-instances)+# `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 not encompassed by `text-show`. Currently, `text-show-instances` covers these libraries:+`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)@@ -12,10 +15,12 @@ * [`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)
+ src/Text/Show/Text/Compiler.hs view
@@ -0,0 +1,13 @@+{-|+Module: Text.Show.Text.Compiler+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Experimental+Portability: GHC++Imports 'Show' instances for @Compiler@ modules.+-}+module Text.Show.Text.Compiler () where++import Text.Show.Text.Compiler.Hoopl ()
+ src/Text/Show/Text/Compiler/Hoopl.hs view
@@ -0,0 +1,194 @@+{-# LANGUAGE CPP, GADTs, OverloadedStrings, 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(..))++#if !(MIN_VERSION_base(4,8,0))+import Data.Monoid (mconcat)+#endif++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)
src/Text/Show/Text/Data.hs view
@@ -10,10 +10,12 @@ -} module Text.Show.Text.Data () where +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 ()
+ src/Text/Show/Text/Data/Binary.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE CPP, 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 Prelude hiding (Show)++import Text.Show.Text (Show(showb, showbPrec), Show1(showbPrec1), Builder, fromString)+import Text.Show.Text.Utils ((<>))++#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)
+ src/Text/Show/Text/Data/String/UTF8.hs view
@@ -0,0 +1,63 @@+{-# LANGUAGE CPP, 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+#if !(MIN_VERSION_base(4,8,0))+import Data.Monoid (mempty)+#endif+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/Time.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE CPP, OverloadedStrings #-}+#if MIN_VERSION_time(1,5,0)+{-# LANGUAGE TemplateHaskell #-}+#endif {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module: Text.Show.Text.Data.Time@@ -22,9 +25,13 @@ , showbTimeOfDay , showbLocalTime , showbZonedTime+#if MIN_VERSION_time(1,5,0)+ , showbTimeLocalePrec+#endif ) where import Data.Fixed (Pico)+import Data.Semigroup (timesN) import Data.Time.Calendar (Day, toGregorian) import Data.Time.Clock (DiffTime, UTCTime, NominalDiffTime) import Data.Time.Clock.TAI (AbsoluteTime, taiToUTCTime)@@ -34,13 +41,19 @@ import Prelude hiding (Show) -import Text.Show.Text (Builder, Show(showb), fromString,- lengthB, replicateB, showbSpace,- FromStringShow(..))+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'.@@ -119,7 +132,7 @@ padN :: Int -> Char -> Builder -> Builder padN i _ b | i <= 0 = b-padN i c b = replicateB (fromIntegral i) (s c) <> b+padN i c b = timesN (fromIntegral i) (s c) <> b {-# INLINE padN #-} showb2 :: (Num t, Ord t, Show t) => NumericPadOption -> t -> Builder@@ -143,7 +156,6 @@ <> showb2 zeroOpt d where (y,m,d) = toGregorian date-{-# INLINE showbGregorian #-} showbPaddedMin :: (Num t, Ord t, Show t) => Int -> NumericPadOption -> t -> Builder showbPaddedMin _ Nothing i = showb i@@ -151,7 +163,6 @@ showbPaddedMin pl (Just c) i = let b = showb i in padN (pl - fromIntegral (lengthB b)) c b-{-# INLINE showbPaddedMin #-} showbT :: NumericPadOption -> Int -> Builder showbT opt t = showb4 opt ((div t 60) * 100 + (mod t 60))@@ -170,6 +181,16 @@ 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)@@ -205,3 +226,7 @@ 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/Vector.hs view
@@ -36,7 +36,7 @@ import Prelude hiding (Show) import Text.Show.Text (Show(showbPrec), Show1(showbPrec1), Builder)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) import Text.Show.Text.Utils (showbUnaryList) #include "inline.h"@@ -103,4 +103,4 @@ showbPrec1 = showbVectorPrec INLINE_INST_FUN(showbPrec1) -$(deriveShowPragmas defaultInlineShowbPrec ''Size)+$(deriveShow ''Size)
src/Text/Show/Text/Instances.hs view
@@ -12,6 +12,7 @@ -} module Text.Show.Text.Instances () where +import Text.Show.Text.Compiler () import Text.Show.Text.Data () import Text.Show.Text.Language () import Text.Show.Text.System ()
src/Text/Show/Text/Language/Haskell/TH.hs view
@@ -41,9 +41,7 @@ #else , showbInlineSpecPrec #endif-#if !(MIN_VERSION_template_haskell(2,8,0)) , showbKindPrec-#endif , showbLitPrec , showbLocPrec , showbMatchPrec@@ -61,9 +59,7 @@ #endif , showbPkgNamePrec , showbPragmaPrec-#if !(MIN_VERSION_template_haskell(2,10,0)) , showbPredPrec-#endif , showbRangePrec #if MIN_VERSION_template_haskell(2,9,0) , showbRole@@ -101,12 +97,9 @@ import Text.Show.Text (Show(showb, showbPrec), Builder, fromString, toLazyText) import Text.Show.Text.Data.Integral (showbIntPrec)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowb,- defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) import Text.Show.Text.Utils ((<>), s) -#include "inline.h"- -- | Convert a 'Body' to a 'Builder' with the given precedence. -- -- /Since: 0.1/@@ -198,6 +191,17 @@ showbInfoPrec = showbPrec {-# INLINE showbInfoPrec #-} +-- | 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+{-# INLINE showbKindPrec #-}+ -- | Convert a 'Lit' to a 'Builder' with the given precedence. -- -- /Since: 0.1/@@ -317,6 +321,17 @@ showbPragmaPrec = showbPrec {-# INLINE showbPragmaPrec #-} +-- | 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+{-# INLINE showbPredPrec #-}+ -- | Convert a 'Range' to a 'Builder' with the given precedence. -- -- /Since: 0.1/@@ -417,15 +432,6 @@ showbInlineSpecPrec :: Int -> InlineSpec -> Builder showbInlineSpecPrec = showbPrec {-# INLINE showbInlineSpecPrec #-}---- | Convert a 'Kind' to a 'Builder' with the given precedence.--- This function is only available with @template-haskell-2.7.0.0@ or earlier, as--- 'Kind' is a type synonym for 'Type' in @template-haskell-2.8.0.0@ or later.--- --- /Since: 0.1/-showbKindPrec :: Int -> Kind -> Builder-showbKindPrec = showbPrec-{-# INLINE showbKindPrec #-} #endif #if MIN_VERSION_template_haskell(2,9,0)@@ -478,74 +484,62 @@ {-# INLINE showbTySynEqnPrec #-} #endif -#if !(MIN_VERSION_template_haskell(2,10,0))--- | Convert a 'Pred' to a 'Builder' with the given precedence.--- This function is only available with @template-haskell-2.9.0.0@ or earlier, as--- 'Pred' is a type synonym for 'Type' in @template-haskell-2.10.0.0@ or later.--- --- /Since: 0.1/-showbPredPrec :: Int -> Pred -> Builder-showbPredPrec = showbPrec-{-# INLINE showbPredPrec #-}-#endif--$(deriveShowPragmas defaultInlineShowbPrec ''Body)-$(deriveShowPragmas defaultInlineShowb ''Callconv)-$(deriveShowPragmas defaultInlineShowbPrec ''Clause)-$(deriveShowPragmas defaultInlineShowbPrec ''Con)-$(deriveShowPragmas defaultInlineShowbPrec ''Dec)-$(deriveShowPragmas defaultInlineShowbPrec ''Exp)-$(deriveShowPragmas defaultInlineShowb ''FamFlavour)-$(deriveShowPragmas defaultInlineShowbPrec ''Fixity)-$(deriveShowPragmas defaultInlineShowb ''FixityDirection)-$(deriveShowPragmas defaultInlineShowbPrec ''Foreign)-$(deriveShowPragmas defaultInlineShowbPrec ''FunDep)-$(deriveShowPragmas defaultInlineShowbPrec ''Guard)-$(deriveShowPragmas defaultInlineShowbPrec ''Info)-$(deriveShowPragmas defaultInlineShowbPrec ''Lit)-$(deriveShowPragmas defaultInlineShowbPrec ''Loc)-$(deriveShowPragmas defaultInlineShowbPrec ''Match)-$(deriveShowPragmas defaultInlineShowbPrec ''ModName)+$(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- INLINE_INST_FUN(showb) -$(deriveShowPragmas defaultInlineShowbPrec ''OccName)-$(deriveShowPragmas defaultInlineShowbPrec ''Pat)-$(deriveShowPragmas defaultInlineShowbPrec ''PkgName)-$(deriveShowPragmas defaultInlineShowbPrec ''Pragma)-$(deriveShowPragmas defaultInlineShowbPrec ''Range)-$(deriveShowPragmas defaultInlineShowb ''Safety)-$(deriveShowPragmas defaultInlineShowbPrec ''Stmt)-$(deriveShowPragmas defaultInlineShowb ''Strict)-$(deriveShowPragmas defaultInlineShowbPrec ''Type)-$(deriveShowPragmas defaultInlineShowbPrec ''TyVarBndr)+$(deriveShow ''OccName)+$(deriveShow ''Pat)+$(deriveShow ''PkgName)+$(deriveShow ''Pragma)+$(deriveShow ''Range)+$(deriveShow ''Safety)+$(deriveShow ''Stmt)+$(deriveShow ''Strict)+$(deriveShow ''Type)+$(deriveShow ''TyVarBndr) #if MIN_VERSION_template_haskell(2,5,0) && !(MIN_VERSION_template_haskell(2,7,0))-$(deriveShowPragmas defaultInlineShowbPrec ''ClassInstance)+$(deriveShow ''ClassInstance) #endif #if MIN_VERSION_template_haskell(2,8,0)-$(deriveShowPragmas defaultInlineShowb ''Inline)-$(deriveShowPragmas defaultInlineShowbPrec ''Phases)-$(deriveShowPragmas defaultInlineShowbPrec ''RuleBndr)-$(deriveShowPragmas defaultInlineShowb ''RuleMatch)-$(deriveShowPragmas defaultInlineShowbPrec ''TyLit)+$(deriveShow ''Inline)+$(deriveShow ''Phases)+$(deriveShow ''RuleBndr)+$(deriveShow ''RuleMatch)+$(deriveShow ''TyLit) #else-$(deriveShowPragmas defaultInlineShowb ''InlineSpec)-$(deriveShowPragmas defaultInlineShowbPrec ''Kind)+$(deriveShow ''InlineSpec)+$(deriveShow ''Kind) #endif #if MIN_VERSION_template_haskell(2,9,0)-$(deriveShowPragmas defaultInlineShowbPrec ''AnnLookup)-$(deriveShowPragmas defaultInlineShowbPrec ''AnnTarget)-$(deriveShowPragmas defaultInlineShowbPrec ''Module)-$(deriveShowPragmas defaultInlineShowbPrec ''ModuleInfo)-$(deriveShowPragmas defaultInlineShowb ''Role)-$(deriveShowPragmas defaultInlineShowbPrec ''TySynEqn)+$(deriveShow ''AnnLookup)+$(deriveShow ''AnnTarget)+$(deriveShow ''Module)+$(deriveShow ''ModuleInfo)+$(deriveShow ''Role)+$(deriveShow ''TySynEqn) #endif #if !(MIN_VERSION_template_haskell(2,10,0))-$(deriveShowPragmas defaultInlineShowbPrec ''Pred)+$(deriveShow ''Pred) #endif
src/Text/Show/Text/System.hs view
@@ -11,12 +11,14 @@ -} module Text.Show.Text.System () where -import Text.Show.Text.System.Locale ()-import Text.Show.Text.System.Random ()-import Text.Show.Text.System.Time ()+import Text.Show.Text.System.Console.Haskeline ()+import Text.Show.Text.System.Locale ()+import Text.Show.Text.System.Random ()+import Text.Show.Text.System.Time () #if defined(mingw32_HOST_OS)-import Text.Show.Text.System.Win32 ()+import Text.Show.Text.System.Win32 () #else-import Text.Show.Text.System.Posix ()+import Text.Show.Text.System.Console.Terminfo ()+import Text.Show.Text.System.Posix () #endif
+ src/Text/Show/Text/System/Console/Haskeline.hs view
@@ -0,0 +1,71 @@+{-# LANGUAGE CPP, OverloadedStrings, 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)
+ src/Text/Show/Text/System/Console/Terminfo.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE CPP, TemplateHaskell #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+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.++/Since: 0.2/+-}+module Text.Show.Text.System.Console.Terminfo (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)
src/Text/Show/Text/System/Directory.hs view
@@ -19,7 +19,7 @@ import System.Directory (Permissions) import Text.Show.Text (Show(showbPrec), Builder)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) -- | Convert 'Permissions' to a 'Builder' with the given precedence. -- @@ -28,4 +28,4 @@ showbPermissionsPrec = showbPrec {-# INLINE showbPermissionsPrec #-} -$(deriveShowPragmas defaultInlineShowbPrec ''Permissions)+$(deriveShow ''Permissions)
src/Text/Show/Text/System/Locale.hs view
@@ -8,7 +8,7 @@ Stability: Experimental Portability: GHC -Monomorphic 'Show' function for 'TimeLocale'.+Monomorphic 'Show' function for old 'TimeLocale's. /Since: 0.1/ -}@@ -19,7 +19,7 @@ import Prelude hiding (Show) import Text.Show.Text (Show(showbPrec), Builder)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) -- | Convert a 'TimeLocale' to a 'Builder' with the given precedence. -- @@ -28,4 +28,4 @@ showbTimeLocalePrec = showbPrec {-# INLINE showbTimeLocalePrec #-} -$(deriveShowPragmas defaultInlineShowbPrec ''TimeLocale)+$(deriveShow ''TimeLocale)
src/Text/Show/Text/System/Posix.hs view
@@ -26,7 +26,7 @@ import System.Posix.User (GroupEntry, UserEntry) import Text.Show.Text (Builder, showb, showbPrec)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow, deriveShowPragmas, defaultInlineShowb) -- | Convert an 'RTLDFlags' value to a 'Builder'. -- @@ -63,8 +63,8 @@ showbUserEntryPrec = showbPrec {-# INLINE showbUserEntryPrec #-} -$(deriveShowPragmas defaultInlineShowb ''RTLDFlags)-$(deriveShowPragmas defaultInlineShowbPrec ''DL)-$(deriveShowPragmas defaultInlineShowbPrec ''ProcessStatus)-$(deriveShowPragmas defaultInlineShowbPrec ''GroupEntry)-$(deriveShowPragmas defaultInlineShowbPrec ''UserEntry)+$(deriveShowPragmas defaultInlineShowb ''RTLDFlags)+$(deriveShow ''DL)+$(deriveShow ''ProcessStatus)+$(deriveShow ''GroupEntry)+$(deriveShow ''UserEntry)
src/Text/Show/Text/System/Time.hs view
@@ -27,7 +27,7 @@ calendarTimeToString, toCalendarTime) import Text.Show.Text (Show(showb, showbPrec), Builder, fromString)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) #include "inline.h" @@ -36,7 +36,6 @@ -- /Since: 0.1/ showbClockTime :: ClockTime -> Builder showbClockTime = fromString . calendarTimeToString . unsafePerformIO . toCalendarTime-{-# INLINE showbClockTime #-} -- | Convert a 'TimeDiff' to a 'Builder' with the given precedence. -- @@ -70,7 +69,7 @@ showb = showbClockTime INLINE_INST_FUN(showb) -$(deriveShowPragmas defaultInlineShowbPrec ''TimeDiff)-$(deriveShowPragmas defaultInlineShowbPrec ''CalendarTime)-$(deriveShowPragmas defaultInlineShowb ''Month)-$(deriveShowPragmas defaultInlineShowb ''Day)+$(deriveShow ''TimeDiff)+$(deriveShow ''CalendarTime)+$(deriveShow ''Month)+$(deriveShow ''Day)
src/Text/Show/Text/System/Win32.hs view
@@ -32,7 +32,8 @@ import System.Win32.Time (FILETIME, SYSTEMTIME, TIME_ZONE_INFORMATION, TimeZoneId) import Text.Show.Text (Builder, showb, showbPrec)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow, deriveShowPragmas,+ defaultInlineShowb, defaultInlineShowbPrec) -- | Convert a 'DebugEventInfo' value to a 'Builder' with the given precedence. -- @@ -104,13 +105,13 @@ showbTimeZoneIdPrec = showb {-# INLINE showbTimeZoneIdPrec #-} -$(deriveShowPragmas defaultInlineShowbPrec ''DebugEventInfo)-$(deriveShowPragmas defaultInlineShowbPrec ''Exception)-$(deriveShowPragmas defaultInlineShowbPrec ''BY_HANDLE_FILE_INFORMATION)-$(deriveShowPragmas defaultInlineShowbPrec ''WIN32_FILE_ATTRIBUTE_DATA)-$(deriveShowPragmas defaultInlineShowbPrec ''ProcessorArchitecture)-$(deriveShowPragmas defaultInlineShowbPrec ''SYSTEM_INFO)+$(deriveShow ''DebugEventInfo)+$(deriveShow ''Exception)+$(deriveShow ''BY_HANDLE_FILE_INFORMATION)+$(deriveShow ''WIN32_FILE_ATTRIBUTE_DATA)+$(deriveShow ''ProcessorArchitecture)+$(deriveShow ''SYSTEM_INFO) $(deriveShowPragmas defaultInlineShowbPrec ''FILETIME)-$(deriveShowPragmas defaultInlineShowbPrec ''SYSTEMTIME)-$(deriveShowPragmas defaultInlineShowbPrec ''TIME_ZONE_INFORMATION)+$(deriveShow ''SYSTEMTIME)+$(deriveShow ''TIME_ZONE_INFORMATION) $(deriveShowPragmas defaultInlineShowb ''TimeZoneId)
src/Text/Show/Text/Text/PrettyPrint.hs view
@@ -14,6 +14,7 @@ -} module Text.Show.Text.Text.PrettyPrint ( showbDoc+ , renderStyleB , showbMode , showbStylePrec , showbTextDetailsPrec@@ -32,22 +33,34 @@ 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 (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow, deriveShowPragmas, defaultInlineShowb) import Text.Show.Text.Utils ((<>), s) #include "inline.h" --- | Convert a 'Doc' to a 'Builder'.+-- | Convert a 'Doc' to a 'Builder'. This is analogous to @render@ from+-- "Text.PrettyPrint.HughesPJ", which renders a 'Doc' using the default 'style'. -- -- /Since: 0.1/ showbDoc :: Doc -> Builder-showbDoc doc = fullRender (mode style) (lineLength style)- (ribbonsPerLine style)- txtPrinter mempty doc+showbDoc = renderStyleB style {-# INLINE showbDoc #-} +-- | 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@@ -90,8 +103,8 @@ INLINE_INST_FUN(showb) $(deriveShowPragmas defaultInlineShowb ''Mode)-$(deriveShowPragmas defaultInlineShowbPrec ''Style)-$(deriveShowPragmas defaultInlineShowbPrec ''TextDetails)+$(deriveShow ''Style)+$(deriveShow ''TextDetails) #if MIN_VERSION_pretty(1,1,2) $(deriveShowPragmas defaultInlineShowbPrec ''PrettyLevel)
src/Text/Show/Text/Text/XHtml.hs view
@@ -28,7 +28,7 @@ import Text.Show.Text (Show(..), Builder, FromStringShow(..), fromString) import Text.Show.Text.Data.Char (showbString)-import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow) import Text.Show.Text.Utils ((<>), s) import Text.XHtml.Frameset (Html, HtmlAttr, HotLink, htmlAttrPair, renderHtmlFragment)@@ -83,7 +83,7 @@ showb = showbHtmlAttr INLINE_INST_FUN(showb) -$(deriveShowPragmas defaultInlineShowbPrec ''HotLink)+$(deriveShow ''HotLink) instance Show HtmlTable where showb = showbHtmlTable
src/Text/Show/Text/Trace/Hpc.hs view
@@ -27,7 +27,8 @@ 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 (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)+import Text.Show.Text.TH (deriveShow, deriveShowPragmas,+ defaultInlineShowb, defaultInlineShowbPrec) import Text.Show.Text.Utils ((<>), s) import Trace.Hpc.Mix (Mix, BoxLabel, CondBox)@@ -89,11 +90,11 @@ showbHash = showb . FromStringShow {-# INLINE showbHash #-} -$(deriveShowPragmas defaultInlineShowbPrec ''Mix)-$(deriveShowPragmas defaultInlineShowbPrec ''BoxLabel)+$(deriveShow ''Mix)+$(deriveShow ''BoxLabel) $(deriveShowPragmas defaultInlineShowb ''CondBox) $(deriveShowPragmas defaultInlineShowbPrec ''Tix)-$(deriveShowPragmas defaultInlineShowbPrec ''TixModule)+$(deriveShow ''TixModule) instance Show HpcPos where showb = showbHpcPos
+ tests/Instances/Compiler/Hoopl.hs view
@@ -0,0 +1,72 @@+{-# LANGUAGE CPP, FlexibleInstances, GeneralizedNewtypeDeriving, 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(..))++#if !(MIN_VERSION_base(4,8,0))+import Control.Applicative (pure)+#endif++import Data.Functor ((<$>))++import Instances.Utils ((<@>))++import Test.Tasty.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/Data/Binary.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE CPP #-}+{-# 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++#if !(MIN_VERSION_base(4,8,0))+import Control.Applicative ((<*>))+#endif++import Data.Binary.Get.Internal (Decoder(..))+import Data.Functor ((<$>))++import Test.QuickCheck.Instances ()+import Test.Tasty.QuickCheck (Arbitrary(..), oneof)++instance Arbitrary a => Arbitrary (Decoder a) where+ arbitrary = oneof [ Fail <$> arbitrary <*> arbitrary+ , Partial <$> arbitrary+ , Done <$> arbitrary <*> arbitrary+ , BytesRead <$> arbitrary <*> arbitrary+ ]
+ tests/Instances/Data/String/UTF8.hs view
@@ -0,0 +1,20 @@+{-# 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.Functor ((<$>))+import Data.String.UTF8 (UTF8, fromRep)++import Test.Tasty.QuickCheck (Arbitrary(..))++instance Arbitrary a => Arbitrary (UTF8 a) where+ arbitrary = fromRep <$> arbitrary
tests/Instances/Language/Haskell/TH.hs view
@@ -25,12 +25,14 @@ import GHC.Exts (Int(I#)) #endif +import Instances.Utils ((<@>))+ import Language.Haskell.TH.Syntax #if !(MIN_VERSION_template_haskell(2,8,0)) import Language.Haskell.TH.Syntax.Internals #endif -import Test.Tasty.QuickCheck (Arbitrary(..), oneof)+import Test.Tasty.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) instance Arbitrary Body where arbitrary = oneof $ map pure [ GuardedB [(fGuard, fExp)]@@ -38,15 +40,10 @@ ] -- arbitrary = oneof [GuardedB <$> arbitrary, NormalB <$> arbitrary] +deriving instance Bounded Callconv+deriving instance Enum Callconv instance Arbitrary Callconv where- arbitrary = oneof $ map pure [ CCall- , StdCall-#if MIN_VERSION_template_haskell(2,10,0)- , CApi- , Prim- , JavaScript-#endif- ]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Clause where arbitrary = pure $ Clause [fPat] fBody [fDec]@@ -56,7 +53,7 @@ arbitrary = oneof [ NormalC <$> arbitrary <*> arbitrary , RecC <$> arbitrary <*> arbitrary , InfixC <$> arbitrary <*> arbitrary <*> arbitrary- , (flip . flip ForallC) [fPred] fCon <$> arbitrary+ , ForallC <$> arbitrary <@> [fPred] <@> fCon ] -- arbitrary = oneof [ NormalC <$> arbitrary <*> arbitrary -- , RecC <$> arbitrary <*> arbitrary@@ -66,14 +63,13 @@ instance Arbitrary Dec where arbitrary = oneof [- flip FunD [fClause] <$> arbitrary+ FunD <$> arbitrary <@> [fClause] , pure $ ValD fPat fBody [fDec] , DataD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary , NewtypeD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary , TySynD <$> arbitrary <*> arbitrary <*> arbitrary- , (flip . ((flip . (flip .)) .) . ClassD) [fPred] [fDec]- <$> arbitrary <*> arbitrary <*> arbitrary- , (flip . InstanceD) [fPred] [fDec] <$> arbitrary+ , ClassD [fPred] <$> arbitrary <*> arbitrary <*> arbitrary <@> [fDec]+ , InstanceD [fPred] <$> arbitrary <@> [fDec] , SigD <$> arbitrary <*> arbitrary , ForeignD <$> arbitrary , PragmaD <$> arbitrary@@ -146,7 +142,7 @@ , pure $ ArithSeqE fRange , pure $ ListE [fExp] , SigE fExp <$> arbitrary- , flip RecConE [fFieldExp] <$> arbitrary+ , RecConE <$> arbitrary <@> [fFieldExp] , pure $ RecUpdE fExp [fFieldExp] #if MIN_VERSION_template_haskell(2,6,0) , pure $ UnboxedTupE [fExp]@@ -196,14 +192,18 @@ -- #endif -- ] +deriving instance Bounded FamFlavour+deriving instance Enum FamFlavour instance Arbitrary FamFlavour where- arbitrary = oneof $ map pure [TypeFam, DataFam]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Fixity where arbitrary = Fixity <$> arbitrary <*> arbitrary +deriving instance Bounded FixityDirection+deriving instance Enum FixityDirection instance Arbitrary FixityDirection where- arbitrary = oneof $ map pure [InfixL, InfixR, InfixN]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Foreign where arbitrary = oneof [ ImportF <$> arbitrary <*> arbitrary <*> arbitrary@@ -277,7 +277,7 @@ #endif instance Arbitrary Match where- arbitrary = (flip . flip Match) fBody [fDec] <$> arbitrary+ arbitrary = Match <$> arbitrary <@> fBody <@> [fDec] -- arbitrary = Match <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary Name where@@ -296,25 +296,28 @@ , NameG <$> arbitrary <*> arbitrary <*> arbitrary ] -instance Arbitrary NameIs where- arbitrary = oneof $ map pure [Alone, Applied, Infix]-+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 = oneof $ map pure [VarName, DataName, TcClsName]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Pat where arbitrary = oneof [ LitP <$> arbitrary , VarP <$> arbitrary , pure $ TupP [fPat]- , flip ConP [fPat] <$> arbitrary- , (flip . InfixP) fPat fPat <$> arbitrary+ , ConP <$> arbitrary <@> [fPat]+ , InfixP fPat <$> arbitrary <@> fPat , pure $ TildeP fPat , pure $ BangP fPat- , flip AsP fPat <$> arbitrary+ , AsP <$> arbitrary <@> fPat , pure WildP- , flip RecP [fFieldPat] <$> arbitrary+ , RecP <$> arbitrary <@> [fFieldPat] , pure $ ListP [fPat] , SigP fPat <$> arbitrary #if MIN_VERSION_template_haskell(2,5,0)@@ -324,7 +327,7 @@ , pure $ UnboxedTupP [fPat] #endif #if MIN_VERSION_template_haskell(2,7,0)- , (flip . UInfixP) fPat fPat <$> arbitrary+ , UInfixP fPat <$> arbitrary <@> fPat , pure $ ParensP fPat #endif ]@@ -385,15 +388,10 @@ -- , FromThenToR <$> arbitrary <*> arbitrary <*> arbitrary -- ] +deriving instance Bounded Safety+deriving instance Enum Safety instance Arbitrary Safety where- arbitrary = oneof $ map pure [ Unsafe- , Safe-#if MIN_VERSION_template_haskell(2,6,0)- , Interruptible-#else- , Threadsafe-#endif- ]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Stmt where arbitrary = oneof $ map pure [ BindS fPat fExp@@ -407,13 +405,10 @@ -- , ParS <$> arbitrary -- ] +deriving instance Bounded Strict+deriving instance Enum Strict instance Arbitrary Strict where- arbitrary = oneof $ map pure [ IsStrict- , NotStrict-#if MIN_VERSION_template_haskell(2,7,0)- , Unpacked-#endif- ]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Type where arbitrary = oneof [ pure $ ForallT [fTyVarBndr] [fPred] fType@@ -466,9 +461,7 @@ -- ] instance Arbitrary TyVarBndr where- arbitrary = oneof [ PlainTV <$> arbitrary- , flip KindedTV fKind <$> arbitrary- ]+ 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))@@ -478,8 +471,10 @@ #endif #if MIN_VERSION_template_haskell(2,8,0)+deriving instance Bounded Inline+deriving instance Enum Inline instance Arbitrary Inline where- arbitrary = oneof $ map pure [NoInline, Inline, Inlinable]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Phases where arbitrary = oneof [ pure AllPhases@@ -490,8 +485,10 @@ instance Arbitrary RuleBndr where arbitrary = oneof [RuleVar <$> arbitrary, TypedRuleVar <$> arbitrary <*> arbitrary] +deriving instance Bounded RuleMatch+deriving instance Enum RuleMatch instance Arbitrary RuleMatch where- arbitrary = oneof $ map pure [ConLike, FunLike]+ arbitrary = arbitraryBoundedEnum instance Arbitrary TyLit where arbitrary = oneof [NumTyLit <$> arbitrary, StrTyLit <$> arbitrary]@@ -520,8 +517,10 @@ instance Arbitrary ModuleInfo where arbitrary = ModuleInfo <$> arbitrary +deriving instance Bounded Role+deriving instance Enum Role instance Arbitrary Role where- arbitrary = oneof $ map pure [NominalR, RepresentationalR, PhantomR, InferR]+ arbitrary = arbitraryBoundedEnum instance Arbitrary TySynEqn where arbitrary = TySynEqn <$> arbitrary <*> arbitrary@@ -529,7 +528,7 @@ #if !(MIN_VERSION_template_haskell(2,10,0)) instance Arbitrary Pred where- arbitrary = oneof [ flip ClassP [fType] <$> arbitrary+ arbitrary = oneof [ ClassP <$> arbitrary <@> [fType] , pure $ EqualP fType fType ] -- arbitrary = oneof [ ClassP <$> arbitrary <*> arbitrary
tests/Instances/Miscellaneous.hs view
@@ -19,6 +19,7 @@ #endif import Data.Functor ((<$>))+import Data.Version (Version(..)) import Foreign.C.Types (CInt(..)) import Foreign.Ptr (Ptr, nullPtr, plusPtr)@@ -38,6 +39,10 @@ instance Arbitrary (Ptr a) where arbitrary = plusPtr nullPtr <$> arbitrary++instance Arbitrary Version where+ arbitrary = pure $ Version [0] [""]+-- arbitrary = Version <$> arbitrary <*> arbitrary deriving instance Arbitrary CInt #if defined(HTYPE_GID_T)
+ tests/Instances/System/Console/Haskeline.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE CPP #-}+{-# 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++#if !(MIN_VERSION_base(4,8,0))+import Control.Applicative ((<*>), pure)+#endif++import Data.Functor ((<$>))++import Instances.Utils ((<@>))++import System.Console.Haskeline (Interrupt(..))+import System.Console.Haskeline.Completion (Completion(..))+import System.Console.Haskeline.History (History, addHistory, emptyHistory)++import Test.Tasty.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
@@ -0,0 +1,34 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-|+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 !(MIN_VERSION_base(4,8,0))+import Control.Applicative (pure)+#endif+import Data.Functor ((<$>))+import System.Console.Terminfo.Color (Color(..))+import Test.Tasty.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
tests/Instances/System/Locale.hs view
@@ -8,7 +8,7 @@ Stability: Experimental Portability: GHC -Provides an 'Arbitrary' instance for 'TimeLocale' values.+Provides an 'Arbitrary' instance for old 'TimeLocale' values. -} module Instances.System.Locale () where
tests/Instances/System/Posix.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP, StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module: Instances.System.Posix@@ -24,10 +24,12 @@ import System.Posix.Process (ProcessStatus(..)) import System.Posix.User (GroupEntry(..), UserEntry(..)) -import Test.Tasty.QuickCheck (Arbitrary(..), oneof)+import Test.Tasty.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) +deriving instance Bounded RTLDFlags+deriving instance Enum RTLDFlags instance Arbitrary RTLDFlags where- arbitrary = oneof $ map pure [RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL]+ arbitrary = arbitraryBoundedEnum instance Arbitrary DL where arbitrary = oneof [pure Null, pure Next, pure Default, DLHandle <$> arbitrary]
tests/Instances/System/Win32.hs view
@@ -26,7 +26,7 @@ import System.Win32.Time (FILETIME(..), SYSTEMTIME(..), TIME_ZONE_INFORMATION(..), TimeZoneId(..)) -import Test.Tasty.QuickCheck (Arbitrary(..), oneof)+import Test.Tasty.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) instance Arbitrary DebugEventInfo where arbitrary = oneof [ pure UnknownDebugEvent@@ -98,5 +98,7 @@ arbitrary = TIME_ZONE_INFORMATION <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary +deriving instance Bounded TimeZoneId+deriving instance Enum TimeZoneId instance Arbitrary TimeZoneId where- arbitrary = oneof $ map pure [TzIdUnknown, TzIdStandard, TzIdDaylight]+ arbitrary = arbitraryBoundedEnum
tests/Instances/Text/PrettyPrint.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE CPP, StandaloneDeriving #-}+#if MIN_VERSION_pretty(1,1,2)+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+#endif {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module: Instances.Text.PrettyPrint@@ -14,12 +17,12 @@ module Instances.Text.PrettyPrint () where #if !(MIN_VERSION_base(4,8,0))-import Control.Applicative ((<*>), pure)+import Control.Applicative ((<*>)) #endif import Data.Functor ((<$>)) -import Test.Tasty.QuickCheck (Arbitrary(..), oneof)+import Test.Tasty.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) import Text.PrettyPrint.HughesPJ (Doc, Mode(..), Style(..), TextDetails(..), text) #if MIN_VERSION_pretty(1,1,2)@@ -29,8 +32,10 @@ instance Arbitrary Doc where arbitrary = text <$> arbitrary +deriving instance Bounded Mode+deriving instance Enum Mode instance Arbitrary Mode where- arbitrary = oneof $ map pure [PageMode, ZigZagMode, LeftMode, OneLineMode]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Style where arbitrary = Style <$> arbitrary <*> arbitrary <*> arbitrary
tests/Instances/Trace/Hpc.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP, StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module: Instances.Trace.Hpc@@ -13,21 +13,23 @@ module Instances.Trace.Hpc () where #if !(MIN_VERSION_base(4,8,0))-import Control.Applicative ((<*>), pure)+import Control.Applicative ((<*>)) #endif import Data.Functor ((<$>)) +import Instances.Utils ((<@>))+ import Test.QuickCheck.Instances ()-import Test.Tasty.QuickCheck (Arbitrary(..), oneof)+import Test.Tasty.QuickCheck (Arbitrary(..), arbitraryBoundedEnum, oneof) 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 = flip (flip . ((flip . (flip .)) .) . Mix) [fMixEntry]- <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary+ arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary <@> [fMixEntry] -- arbitrary = Mix <$> arbitrary <*> arbitrary <*> arbitrary -- <*> arbitrary <*> arbitrary @@ -38,8 +40,10 @@ , BinBox <$> arbitrary <*> arbitrary ] +deriving instance Bounded CondBox+deriving instance Enum CondBox instance Arbitrary CondBox where- arbitrary = oneof $ map pure [GuardBinBox, CondBinBox, QualBinBox]+ arbitrary = arbitraryBoundedEnum instance Arbitrary Tix where arbitrary = Tix <$> arbitrary
+ tests/Instances/Utils.hs view
@@ -0,0 +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
tests/Properties.hs view
@@ -11,20 +11,25 @@ -} module Main (main) where +import Properties.Compiler.Hoopl (hooplTests) import Properties.Control.Applicative.Trans (applicativeFunctorTransformerTests) import Properties.Control.Monad.Trans (monadTransformerTests)+import Properties.Data.Binary (binaryTests) import Properties.Data.Containers (containersTests) import Properties.Data.Functor.Trans (functorTransformerTests) import Properties.Data.List.NonEmpty (nonEmptyListTests) import Properties.Data.Semigroup (semigroupTests)+import Properties.Data.String.UTF8 (utf8StringTests) import Properties.Data.Tagged (taggedTests) import Properties.Data.Time (timeTests) import Properties.Data.UnorderedContainers (unorderedContainersTests) import Properties.Data.Vector (vectorTests) import Properties.Language.Haskell.TH (templateHaskellTests)+import Properties.System.Console.Haskeline (haskelineTests) import Properties.System.Directory (directoryTests) import Properties.System.Locale (oldLocaleTests) #if !defined(mingw32_HOST_OS)+import Properties.System.Console.Terminfo (terminfoTests) import Properties.System.Posix (unixTests) #endif import Properties.System.Random (randomTests)@@ -41,21 +46,29 @@ main :: IO () main = defaultMain testTree +testTree :: TestTree+testTree = testGroup "QuickCheck properties" allTests+ allTests :: [TestTree]-allTests = concat [ applicativeFunctorTransformerTests+allTests = concat [ hooplTests+ , applicativeFunctorTransformerTests , monadTransformerTests+ , binaryTests , containersTests , functorTransformerTests , nonEmptyListTests , semigroupTests+ , utf8StringTests , taggedTests , timeTests , unorderedContainersTests , vectorTests , templateHaskellTests+ , haskelineTests , directoryTests , oldLocaleTests #if !defined(mingw32_HOST_OS)+ , terminfoTests , unixTests #endif , randomTests@@ -67,6 +80,3 @@ , xhtmlTests , hpcTests ]--testTree :: TestTree-testTree = testGroup "QuickCheck properties" allTests
+ tests/Properties/Compiler/Hoopl.hs view
@@ -0,0 +1,40 @@+{-|+Module: Properties.Compiler.Hoopl+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 @hoopl@ library.+-}+module Properties.Compiler.Hoopl (hooplTests) 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 Properties.Utils (prop_matchesShow)++import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty)++import Text.Show.Text.Compiler.Hoopl ()++hooplTests :: [TestTree]+hooplTests =+ [ testGroup "Text.Show.Text.Compiler.Hoopl"+ [ testProperty "Label instance" (prop_matchesShow :: Int -> Label -> Bool)+ , testProperty "LabelMap Char instance" (prop_matchesShow :: Int -> LabelMap Char -> Bool)+ , testProperty "LabelSet instance" (prop_matchesShow :: Int -> LabelSet -> Bool)+ , testProperty "Pointed C C Int instance" (prop_matchesShow :: Int -> Pointed C C Int -> Bool)+ , testProperty "Unique instance" (prop_matchesShow :: Int -> Unique -> Bool)+ , testProperty "UniqueMap Char instance" (prop_matchesShow :: Int -> UniqueMap Char -> Bool)+ , testProperty "UniqueSet instance" (prop_matchesShow :: Int -> UniqueSet -> Bool)+ , testProperty "DominatorNode instance" (prop_matchesShow :: Int -> DominatorNode -> Bool)+ , testProperty "DominatorTree instance" (prop_matchesShow :: Int -> DominatorTree -> Bool)+ , testProperty "DPath instance" (prop_matchesShow :: Int -> DPath -> Bool)+ ]+ ]
+ tests/Properties/Data/Binary.hs view
@@ -0,0 +1,29 @@+{-|+Module: Properties.Data.Binary+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Experimental+Portability: GHC++@QuickCheck@ properties for 'Decoder's.+-}+module Properties.Data.Binary (binaryTests) where++import Data.Binary.Get.Internal (Decoder)++import Instances.Data.Binary ()++import Properties.Utils (prop_matchesShow)++import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty)++import Text.Show.Text.Data.Binary ()++binaryTests :: [TestTree]+binaryTests =+ [ testGroup "Text.Show.Text.Data.Binary"+ [ testProperty "Decoder Int instance" (prop_matchesShow :: Int -> Decoder Int -> Bool)+ ]+ ]
+ tests/Properties/Data/String/UTF8.hs view
@@ -0,0 +1,35 @@+{-|+Module: Properties.Data.String.UTF8+Copyright: (C) 2014-2015 Ryan Scott+License: BSD-style (see the file LICENSE)+Maintainer: Ryan Scott+Stability: Experimental+Portability: GHC++@QuickCheck@ properties for 'UTF8' strings.+-}+module Properties.Data.String.UTF8 (utf8StringTests) 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 Properties.Utils (prop_matchesShow)++import Test.QuickCheck.Instances ()+import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty)++import Text.Show.Text.Data.String.UTF8 ()++utf8StringTests :: [TestTree]+utf8StringTests =+ [ testGroup "Text.Show.Text.Data.String.UTF8"+ [ testProperty "UTF8 ByteString (strict) instance" (prop_matchesShow :: Int -> UTF8 BS.ByteString -> Bool)+ , testProperty "UTF8 ByteString (lazy) instance" (prop_matchesShow :: Int -> UTF8 BL.ByteString -> Bool)+ , testProperty "UTF8 [Word8] instance" (prop_matchesShow :: Int -> UTF8 [Word8] -> Bool)+ ]+ ]
tests/Properties/Language/Haskell/TH.hs view
@@ -56,9 +56,7 @@ #else , testProperty "InlineSpec instance" (prop_matchesShow :: Int -> InlineSpec -> Bool) #endif-#if !(MIN_VERSION_template_haskell(2,8,0)) , testProperty "Kind instance" (prop_matchesShow :: Int -> Kind -> Bool)-#endif , testProperty "Lit instance" (prop_matchesShow :: Int -> Lit -> Bool) , testProperty "Loc instance" (prop_matchesShow :: Int -> Loc -> Bool) , testProperty "Match instance" (prop_matchesShow :: Int -> Match -> Bool)@@ -75,9 +73,7 @@ , testProperty "Phases instance" (prop_matchesShow :: Int -> Phases -> Bool) #endif , testProperty "PkgName instance" (prop_matchesShow :: Int -> PkgName -> Bool)-#if !(MIN_VERSION_template_haskell(2,10,0)) , testProperty "Pred instance" (prop_matchesShow :: Int -> Pred -> Bool)-#endif , testProperty "Pragma instance" (prop_matchesShow :: Int -> Pragma -> Bool) , testProperty "Range instance" (prop_matchesShow :: Int -> Range -> Bool) #if MIN_VERSION_template_haskell(2,9,0)
+ tests/Properties/System/Console/Haskeline.hs view
@@ -0,0 +1,37 @@+{-|+Module: Properties.System.Console.Haskeline+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 @haskeline@ library.+-}+module Properties.System.Console.Haskeline (haskelineTests) where++import Instances.System.Console.Haskeline ()++import Properties.Utils (prop_matchesShow)++import System.Console.Haskeline (Interrupt, defaultPrefs)+import System.Console.Haskeline.Completion (Completion)+import System.Console.Haskeline.History (History)++import Test.Tasty (TestTree, testGroup)+import Test.Tasty.HUnit ((@=?), testCase)+import Test.Tasty.QuickCheck (testProperty)++import Text.Show.Text (FromStringShow(..), showb)+import Text.Show.Text.System.Console.Haskeline ()++haskelineTests :: [TestTree]+haskelineTests =+ [ testGroup "Text.Show.Text.System.Console.Haskeline"+ [ testProperty "Interrupt instance" (prop_matchesShow :: Int -> Interrupt -> Bool)+-- , testProperty "Prefs instance" (prop_matchesShow :: Int -> Prefs -> Bool)+ , testCase "defaultPrefs Show output" $ showb (FromStringShow defaultPrefs) @=? showb defaultPrefs+ , testProperty "Completion instance" (prop_matchesShow :: Int -> Completion -> Bool)+ , testProperty "History instance" (prop_matchesShow :: Int -> History -> Bool)+ ]+ ]
+ tests/Properties/System/Console/Terminfo.hs view
@@ -0,0 +1,30 @@+{-|+Module: Properties.System.Console.Terminfo+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 @terminfo@ library.+-}+module Properties.System.Console.Terminfo (terminfoTests) where++import Instances.System.Console.Terminfo ()++import Properties.Utils (prop_matchesShow)++import System.Console.Terminfo.Color (Color)++import Test.Tasty (TestTree, testGroup)+import Test.Tasty.QuickCheck (testProperty)++import Text.Show.Text.System.Console.Terminfo ()++terminfoTests :: [TestTree]+terminfoTests =+ [ testGroup "Text.Show.Text.System.Console.Terminfo"+ [ testProperty "Color instance" (prop_matchesShow :: Int -> Color -> Bool)+-- , testProperty "SetupTermError instance" (prop_matchesShow :: Int -> SetupTermError -> Bool)+ ]+ ]
tests/Properties/System/Directory.hs view
@@ -11,8 +11,6 @@ -} module Properties.System.Directory (directoryTests) where -import Test.Tasty (TestTree)- #if MIN_VERSION_directory(1,1,0) import Instances.System.Directory () @@ -20,7 +18,7 @@ import System.Directory (Permissions) -import Test.Tasty (testGroup)+import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) import Text.Show.Text.System.Directory ()
tests/Properties/System/Locale.hs view
@@ -6,7 +6,7 @@ Stability: Experimental Portability: GHC -@QuickCheck@ properties for 'TimeLocale'.+@QuickCheck@ properties for old 'TimeLocale's. -} module Properties.System.Locale (oldLocaleTests) where
tests/Properties/Text/PrettyPrint.hs view
@@ -7,7 +7,7 @@ Stability: Experimental Portability: GHC -@QuickCheck@ properties for 'StdGen' values.+@QuickCheck@ properties for data types in the @pretty@ library. -} module Properties.Text.PrettyPrint (prettyTests) where @@ -18,16 +18,22 @@ import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) -import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails)+import Text.PrettyPrint.HughesPJ (Doc, Mode, Style, TextDetails, renderStyle) #if MIN_VERSION_pretty(1,1,2)-import Text.PrettyPrint.HughesPJClass (TextDetails)+import Text.PrettyPrint.HughesPJClass (PrettyLevel) #endif-import Text.Show.Text.Text.PrettyPrint ()+import Text.Show.Text (fromString)+import Text.Show.Text.Text.PrettyPrint (renderStyleB) +-- | 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+ prettyTests :: [TestTree] prettyTests = [ testGroup "Text.Show.Text.Text.PrettyPrint" [ testProperty "Doc instance" (prop_matchesShow :: Int -> Doc -> Bool)+ , testProperty "rendetStyleB output" prop_renderStyle , testProperty "Mode instance" (prop_matchesShow :: Int -> Mode -> Bool) , testProperty "Style instance" (prop_matchesShow :: Int -> Style -> Bool) , testProperty "TextDetails instance" (prop_matchesShow :: Int -> TextDetails -> Bool)
text-show-instances.cabal view
@@ -1,15 +1,22 @@ name: text-show-instances-version: 0.1.0.1+version: 0.2 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 not encompassed by @text-show@.- Currently, @text-show-instances@ covers these libraries:+ 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>@@@ -26,6 +33,8 @@ . * @<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>@@@ -34,6 +43,8 @@ . * @<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>@@@ -61,24 +72,24 @@ type: git location: git://github.com/RyanGlScott/text-show-instances.git -flag transformers-four- description: Use a recent version of transformers.- default: True- 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@@ -86,7 +97,8 @@ Text.Show.Text.Text.PrettyPrint Text.Show.Text.Text.XHtml Text.Show.Text.Trace.Hpc- other-modules: Text.Show.Text.Control+ other-modules: Text.Show.Text.Compiler+ Text.Show.Text.Control Text.Show.Text.Data Text.Show.Text.Language Text.Show.Text.System@@ -94,8 +106,12 @@ Text.Show.Text.Trace Text.Show.Text.Utils build-depends: base >= 4.2 && < 5+ , 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@@ -104,10 +120,13 @@ , semigroups >= 0.8.4 && < 1 , tagged >= 0.4.4 && < 1 , template-haskell >= 2.4 && < 2.11- , text >= 0.2 && < 1.3- , text-show >= 0.5 && < 0.6+ , text >= 0.8 && < 1.3+ , text-show >= 0.5 && < 0.7 , 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@@ -116,47 +135,52 @@ includes: inline.h install-includes: inline.h - if flag(transformers-four)- build-depends: transformers >= 0.4 && < 0.5- else- build-depends: transformers >= 0.2.1 && < 0.4- , transformers-compat >= 0.3 && < 1- if os(windows) build-depends: Win32 >= 2.1 && < 2.4 exposed-modules: Text.Show.Text.System.Win32 else- build-depends: unix >= 2 && < 2.8- exposed-modules: Text.Show.Text.System.Posix+ build-depends: terminfo >= 0.3.2 && < 0.5+ , unix >= 2 && < 2.8+ exposed-modules: Text.Show.Text.System.Console.Terminfo+ Text.Show.Text.System.Posix test-suite text-show-instances-properties type: exitcode-stdio-1.0 main-is: Properties.hs- other-modules: Instances.Control.Applicative.Trans+ 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+ Properties.Compiler.Hoopl Properties.Control.Applicative.Trans Properties.Control.Monad.Trans+ Properties.Data.Binary Properties.Data.Containers Properties.Data.Functor.Trans Properties.Data.List.NonEmpty Properties.Data.Semigroup+ Properties.Data.String.UTF8 Properties.Data.Tagged Properties.Data.Time Properties.Data.UnorderedContainers Properties.Language.Haskell.TH+ Properties.System.Console.Haskeline Properties.System.Directory Properties.System.Locale Properties.System.Random@@ -166,8 +190,12 @@ Properties.Trace.Hpc Properties.Utils build-depends: base >= 4.5 && < 5+ , 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@@ -177,28 +205,29 @@ , semigroups >= 0.8.4 && < 1 , tagged >= 0.4.4 && < 1 , tasty >= 0.8 && < 0.11+ , tasty-hunit >= 0.8 && < 0.10 , tasty-quickcheck >= 0.8 && < 0.9 , template-haskell >= 2.4 && < 2.11- , text-show >= 0.5 && < 0.6- , text-show-instances == 0.1+ , text-show >= 0.5 && < 0.7+ , text-show-instances == 0.2 , 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 ghc-options: -Wall - if flag(transformers-four)- build-depends: transformers >= 0.4 && < 0.5- else- build-depends: transformers >= 0.2.1 && < 0.4- , transformers-compat >= 0.3 && < 1- if os(windows) build-depends: Win32 >= 2.1 && < 2.4 other-modules: Instances.System.Win32 Properties.System.Win32 else- build-depends: unix >= 2 && < 2.8- other-modules: Instances.System.Posix+ build-depends: terminfo >= 0.3.2 && < 0.5+ , unix >= 2 && < 2.8+ other-modules: Instances.System.Console.Terminfo+ Instances.System.Posix+ Properties.System.Console.Terminfo Properties.System.Posix