prettyprinter-combinators 0.1.1 → 0.1.1.1
raw patch · 8 files changed
+85/−28 lines, 8 filesdep ~pretty-showPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: pretty-show
API changes (from Hackage documentation)
- Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride GHC.Integer.Type.Integer
- Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride GHC.Natural.Natural
- Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride Language.Haskell.TH.Syntax.TyVarBndr
+ Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride GHC.Num.Integer.Integer
+ Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride GHC.Num.Natural.Natural
+ Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride Language.Haskell.TH.Syntax.Specificity
+ Prettyprinter.Generics: instance Prettyprinter.Generics.PPGenericOverride a => Prettyprinter.Generics.PPGenericOverride (Language.Haskell.TH.Syntax.TyVarBndr a)
- Prettyprinter.Combinators: ppVector :: Pretty a => Vector a -> Doc ann
+ Prettyprinter.Combinators: ppVector :: (Vector v a, Pretty a) => v a -> Doc ann
- Prettyprinter.Combinators: ppVectorWith :: (a -> Doc ann) -> Vector a -> Doc ann
+ Prettyprinter.Combinators: ppVectorWith :: Vector v a => (a -> Doc ann) -> v a -> Doc ann
Files
- Changelog.md +3/−0
- Readme.md +47/−0
- prettyprinter-combinators.cabal +26/−16
- src/Prettyprinter/Combinators.hs +4/−6
- src/Prettyprinter/Data.hs +0/−1
- src/Prettyprinter/Generics.hs +0/−1
- src/Prettyprinter/MetaDoc.hs +0/−1
- src/Prettyprinter/Show.hs +5/−3
+ Changelog.md view
@@ -0,0 +1,3 @@+# 0.1.1.1+- `ppVector` and `ppVectorWith` now accept generic vectors+- Add lower bound `pretty-show >= 1.6`
+ Readme.md view
@@ -0,0 +1,47 @@+This is a set of utilities for the Haskell `prettyrinter` package.+Most notable is automatic deriving of `Pretty` instance from the+`Generic` instance, e.g.++```haskell+{-# LANGUAGE DeriveGeneric #-}++import Prettyprinter.Generics++data Foo a b = Bar Int | Baz a b+ deriving (Generic)++instance (Pretty a, Pretty b) => Pretty (Foo a b) where+ pretty = ppGeneric++printed :: Doc ann+printed = pretty $ Baz (Bar 10 :: Foo () ()) [1..22]+```++which would put following into `printed`:++```+Baz+ Bar 10+ [ 1+ , 2+ , 3+ , 4+ , 5+ , 6+ , 7+ , 8+ , 9+ , 10+ , 11+ , 12+ , 13+ , 14+ , 15+ , 16+ , 17+ , 18+ , 19+ , 20+ , 21+ , 22 ]+```
prettyprinter-combinators.cabal view
@@ -3,7 +3,7 @@ name: prettyprinter-combinators version:- 0.1.1+ 0.1.1.1 synopsis: Some useful combinators for the prettyprinter package description:@@ -25,20 +25,30 @@ Sergey Vinokurov <serg.foo@gmail.com> tested-with:- GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.2+ , GHC == 8.10.7+ , GHC == 9.0.2+ , GHC == 9.2.5+ , GHC == 9.4.4 build-type: Simple +extra-source-files:+ Changelog.md+ Readme.md+ homepage: https://github.com/sergv/prettyprinter-combinators source-repository head- type: git- location: https://github.com/sergv/prettyprinter-combinators.git+ type: git+ location: https://github.com/sergv/prettyprinter-combinators.git common ghc-options default-language: Haskell2010 + default-extensions:+ ImportQualifiedPost+ ghc-options: -Weverything -Wno-type-defaults@@ -72,15 +82,15 @@ hs-source-dirs: src build-depends:- base >= 4.14 && <5,- bimap,- bytestring,- containers,- dlist,- prettyprinter >= 1.7,- pretty-show,- syb,- template-haskell >= 2.10,- text,- vector,- unordered-containers+ , base >= 4.14 && <5+ , bimap+ , bytestring+ , containers+ , dlist+ , pretty-show >= 1.6+ , prettyprinter >= 1.7+ , syb+ , template-haskell >= 2.10+ , text+ , unordered-containers+ , vector
src/Prettyprinter/Combinators.hs view
@@ -8,7 +8,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveTraversable #-}-{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -88,8 +87,7 @@ import Data.Map.Strict (Map) import Data.Map.Strict qualified as M import Data.Set (Set)-import Data.Vector (Vector)-import Data.Vector qualified as V+import Data.Vector.Generic qualified as G import GHC.Stack (CallStack, SrcLoc(..), getCallStack, prettySrcLoc) #if !MIN_VERSION_base(4, 11, 0)@@ -231,11 +229,11 @@ ppHashMapWith :: (k -> Doc ann) -> (v -> Doc ann) -> HashMap k v -> Doc ann ppHashMapWith f g = ppAssocListWith f g . HM.toList -ppVector :: Pretty a => Vector a -> Doc ann+ppVector :: (G.Vector v a, Pretty a) => v a -> Doc ann ppVector = ppVectorWith pretty -ppVectorWith :: (a -> Doc ann) -> Vector a -> Doc ann-ppVectorWith f = ppListWith f . V.toList+ppVectorWith :: G.Vector v a => (a -> Doc ann) -> v a -> Doc ann+ppVectorWith f = ppListWith f . G.toList ppDList :: Pretty a => DList a -> Doc ann ppDList = ppDListWith pretty
src/Prettyprinter/Data.hs view
@@ -6,7 +6,6 @@ -- Maintainer : serg.foo@gmail.com ---------------------------------------------------------------------------- -{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-}
src/Prettyprinter/Generics.hs view
@@ -10,7 +10,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}
src/Prettyprinter/MetaDoc.hs view
@@ -6,7 +6,6 @@ -- Maintainer : serg.foo@gmail.com ---------------------------------------------------------------------------- -{-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE ScopedTypeVariables #-} module Prettyprinter.MetaDoc
src/Prettyprinter/Show.hs view
@@ -6,9 +6,9 @@ -- Maintainer : serg.foo@gmail.com ---------------------------------------------------------------------------- -{-# LANGUAGE ImportQualifiedPost #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-} module Prettyprinter.Show (ppShow) where @@ -50,6 +50,8 @@ Float x -> stringMetaDoc x Char x -> stringMetaDoc x String x -> stringMetaDoc x+#if MIN_VERSION_pretty_show (1, 10, 0) Date x -> stringMetaDoc x Time x -> stringMetaDoc x Quote x -> stringMetaDoc x+#endif