pretty-types 0.2.2.0 → 0.2.2.1
raw patch · 2 files changed
+38/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- pretty-types.cabal +1/−1
- src/Data/Type/Pretty.hs +37/−0
pretty-types.cabal view
@@ -1,5 +1,5 @@ name: pretty-types-version: 0.2.2.0+version: 0.2.2.1 synopsis: A small pretty printing DSL for complex types. description: Please see README.md homepage: https://github.com/sheyll/pretty-types#readme
src/Data/Type/Pretty.hs view
@@ -137,26 +137,32 @@ -- ** ToPretty instances for uninhabited types -- | A type of kind 'Symbol' is translated to 'PutStr'.+-- -- @since 0.2.1.0 type instance ToPretty (t :: Symbol) = PutStr t -- | A type of kind 'Nat' is translated to 'PutNat'.+-- -- @since 0.2.1.0 type instance ToPretty (t :: Nat) = PutNat t -- | Render 'True' as @'PutStr' "'True"@+-- -- @since 0.2.1.0 type instance ToPretty 'True = PutStr "'True" -- | Render 'False' as @'PutStr' "'False"@+-- -- @since 0.2.1.0 type instance ToPretty 'False = PutStr "'False" -- | Render a type of kind 'Maybe'.+-- -- @since 0.2.1.0 type instance ToPretty (t :: Maybe x) = ToPrettyMaybe t -- | Render a type of kind 'Maybe'.+-- -- @since 0.2.1.0 type family ToPrettyMaybe (t :: Maybe x) :: PrettyType where ToPrettyMaybe 'Nothing = 'PrettyEmpty@@ -165,54 +171,67 @@ -- ** ToPretty instances for inhabited types -- | Render 'Word8' as @'PutStr' "Word8"@+-- -- @since 0.2.1.0 type instance ToPretty Word8 = PutStr "Word8" -- | Render 'Word16' as @'PutStr' "Word16"@+-- -- @since 0.2.1.0 type instance ToPretty Word16 = PutStr "Word16" -- | Render 'Word32' as @'PutStr' "Word32"@+-- -- @since 0.2.1.0 type instance ToPretty Word32 = PutStr "Word32" -- | Render 'Word64' as @'PutStr' "Word64"@+-- -- @since 0.2.1.0 type instance ToPretty Word64 = PutStr "Word64" -- | Render 'Int8' as @'PutStr' "Int8"@+-- -- @since 0.2.1.0 type instance ToPretty Int8 = PutStr "Int8" -- | Render 'Int16' as @'PutStr' "Int16"@+-- -- @since 0.2.1.0 type instance ToPretty Int16 = PutStr "Int16" -- | Render 'Int32' as @'PutStr' "Int32"@+-- -- @since 0.2.1.0 type instance ToPretty Int32 = PutStr "Int32" -- | Render 'Int64' as @'PutStr' "Int64"@+-- -- @since 0.2.1.0 type instance ToPretty Int64 = PutStr "Int64" -- | Render 'Int' as @'PutStr' "Int"@+-- -- @since 0.2.1.0 type instance ToPretty Int = PutStr "Int" -- | Render 'Integer' as @'PutStr' "Integer"@+-- -- @since 0.2.1.0 type instance ToPretty Integer = PutStr "Integer" -- | Render 'Bool' as @'PutStr' "Bool"@+-- -- @since 0.2.1.0 type instance ToPretty Bool = PutStr "Bool" -- | Render 'Float' as @'PutStr' "Float"@+-- -- @since 0.2.1.0 type instance ToPretty Float = PutStr "Float" -- | Render 'Double' as @'PutStr' "Double"@+-- -- @since 0.2.1.0 type instance ToPretty Double = PutStr "Double" @@ -298,6 +317,7 @@ -- ** Composing Pretty Printers -- | A label followed by a colon and space @: @ followed by another element.+-- -- @since 0.2.0.0 -- -- >>> showPretty (Proxy :: Proxy ("foo" <:> PutStr "bar"))@@ -307,6 +327,7 @@ type (<:>) label body = 'PrettySuffix (PutStr ":") (PutStr label) <+> body infixl 5 <:> -- | Like '<:>' but begin the body on a new line.+-- -- @since 0.2.0.0 -- -- >>> showPretty (Proxy :: Proxy (PutStr "foo" <:$$> PutStr "bar"))@@ -318,6 +339,7 @@ infixl 5 <:$$> -- | Like '<:$$__>' but indent the body with two spaces.+-- -- @since 0.2.0.0 -- -- >>> showPretty (Proxy :: Proxy (PutStr "foo" <:$$--> PutStr "bar"))@@ -337,6 +359,7 @@ infixl 5 <+> -- | Choose the first non-empty from two 'PrettyType's.+-- -- @since 0.2.0.0 type (<||>) l r = 'PrettyAlternative l r infixl 5 <||>@@ -346,6 +369,7 @@ infixl 4 <$$> -- | Concatenate two 'PrettyType' using a 'PrettyNewline' and indent the second.+-- -- @since 0.2.0.0 type (<$$-->) l r = 'PrettyInfix 'PrettyNewline l ('PrettyIndent 2 r) infixl 3 <$$-->@@ -390,6 +414,7 @@ -- *** Pretty Printing 'Tagged' Values -- | Pretty print a 'Tagged' value.+-- -- @since 0.2.2.0 type instance ToPretty (Tagged s b) = ToPretty b <+> PrettyParens (ToPretty s) @@ -410,17 +435,21 @@ PrettySymbol :: PrettyPadded -> PrettyPrecision -> Symbol -> PrettyType PrettyNat :: PrettyPadded -> PrettyPrecision -> PrettyNatFormat -> Nat -> PrettyType -- | Prefix the second with the first argument, but only if it (the second) has content.+ -- -- @since 0.2.0.0 PrettyPrefix :: PrettyType -> PrettyType -> PrettyType -- | Combine the last to arguments with the first in between them, but only if both have content. PrettyInfix :: PrettyType -> PrettyType -> PrettyType -> PrettyType -- | Add a the first argument as suffix to the second argument, but only if the second has content.+ -- -- @since 0.2.0.0 PrettySuffix :: PrettyType -> PrettyType -> PrettyType -- | Indentation. Prefix any line using the given number of 'PrettySpace'.+ -- -- @since 0.2.0.0 PrettyIndent :: Nat -> PrettyType -> PrettyType -- | Alternative rendering, if the first document ist empty the second will be rendered.+ -- -- @since 0.2.0.0 PrettyAlternative :: PrettyType -> PrettyType -> PrettyType @@ -475,15 +504,18 @@ -- String. ptShow :: proxy p -> PTM () -- | Return 'True' if contents would be writting to the output of rendered via 'ptShow'+ -- -- @since 0.2.0.0 ptHasContent :: proxy p -> PTM Bool ptHasContent _ = return True -- | The monad used by 'ptShow' to keep track of indentation.+-- -- @since 0.2.0.0 type PTM a = RWS Indentation String PTRenderState a -- | Internal; write a possibly indented string, and update the 'PTRenderState' accordingly.+-- -- @since 0.2.0.0 writeIndented :: String -> PTM () writeIndented s = do@@ -497,10 +529,12 @@ Control.Monad.RWS.tell s -- | Internal type of the indentation used by 'ptShow' in 'PTM'+-- -- @since 0.2.0.0 type Indentation = Int -- | Internal state used by 'ptShow' in 'PTM'+-- -- @since 0.2.0.0 data PTRenderState = AtBeginningOfLine | AlreadyIndented @@ -567,6 +601,7 @@ ptHasContent _ = ptHasContent (Proxy :: Proxy x) -- | Add a 'PrettyType' suffix to x, but only if 'ptHasContent' holds.+-- -- @since 0.2.0.0 instance forall x sep . (PrettyTypeShow sep, PrettyTypeShow x) => PrettyTypeShow ('PrettySuffix sep x) where@@ -579,6 +614,7 @@ ptHasContent _ = ptHasContent (Proxy :: Proxy x) -- | Render the first document, and if it is empty, the second+-- -- @since 0.2.0.0 instance forall l r . (PrettyTypeShow l, PrettyTypeShow r) => PrettyTypeShow ('PrettyAlternative l r) where@@ -594,6 +630,7 @@ -- | Render an indented, nested type.+-- -- @since 0.2.0.0 instance forall n r . (PrettyTypeShow r, KnownNat n) => PrettyTypeShow ('PrettyIndent n r) where