commit ghc-wl-pprint-text for openSUSE:Factory

Hello community, here is the log from the commit of package ghc-wl-pprint-text for openSUSE:Factory checked in at 2017-02-22 13:53:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-wl-pprint-text (Old) and /work/SRC/openSUSE:Factory/.ghc-wl-pprint-text.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-wl-pprint-text" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-wl-pprint-text/ghc-wl-pprint-text.changes 2016-07-21 08:13:16.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-wl-pprint-text.new/ghc-wl-pprint-text.changes 2017-02-22 13:53:58.204598192 +0100 @@ -1,0 +2,5 @@ +Mon Jan 30 09:26:24 UTC 2017 - psimons@suse.com + +- Update to version 1.1.1.0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- wl-pprint-text-1.1.0.4.tar.gz New: ---- wl-pprint-text-1.1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-wl-pprint-text.spec ++++++ --- /var/tmp/diff_new_pack.3b7Dtm/_old 2017-02-22 13:53:58.804512827 +0100 +++ /var/tmp/diff_new_pack.3b7Dtm/_new 2017-02-22 13:53:58.804512827 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-wl-pprint-text # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,19 +18,18 @@ %global pkg_name wl-pprint-text Name: ghc-%{pkg_name} -Version: 1.1.0.4 +Version: 1.1.1.0 Release: 0 Summary: A Wadler/Leijen Pretty Printer for Text values License: BSD-3-Clause -Group: System/Libraries +Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel +BuildRequires: ghc-base-compat-devel BuildRequires: ghc-rpm-macros -# Begin cabal-rpm deps: BuildRequires: ghc-text-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build -# End cabal-rpm deps %description A clone of wl-pprint for use with the text library. @@ -49,15 +48,12 @@ %prep %setup -q -n %{pkg_name}-%{version} - %build %ghc_lib_build - %install %ghc_lib_install - %post devel %ghc_pkg_recache @@ -70,5 +66,6 @@ %files devel -f %{name}-devel.files %defattr(-,root,root,-) +%doc Changelog.md README.md %changelog ++++++ wl-pprint-text-1.1.0.4.tar.gz -> wl-pprint-text-1.1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wl-pprint-text-1.1.0.4/Changelog.md new/wl-pprint-text-1.1.1.0/Changelog.md --- old/wl-pprint-text-1.1.0.4/Changelog.md 1970-01-01 01:00:00.000000000 +0100 +++ new/wl-pprint-text-1.1.1.0/Changelog.md 2017-01-26 12:56:06.000000000 +0100 @@ -0,0 +1,59 @@ +1.1.1.0 (2017-01-26) +==================== + +* Support strict `Text` values (thanks to Elliot Cameron). + +* Loosened constraints from `Monad` to `Functor` where applicable + (thanks to Elliot Cameron). + +* Uses `base-compat` to make it easier to support multiple GHC + versions. + +* Add `isEmpty :: Doc -> Bool`. + +* Support `Semigroup` in `base >= 4.9.0.0`. + +1.1.0.4 (2015-04-06) +==================== + +* Support `GHC-7.10`. + +1.1.0.3 (2014-12-24) +==================== + +* Support `text-1.2.*`. + +1.1.0.2 (2014-01-16) +==================== + +* Support `text-1.1.0.0`. + +1.1.0.1 (2013-12-23) +==================== + +_This probably should have been 1.1.1.0._ + +* Documentation fixes. + +* Add `displayB`, `spacebreak` and `<++>`. + +* Smarter treatment of spaces, newlines, etc. (including how `line` + behaves in `renderOneLine`). + +1.1.0.0 (2012-08-22) +==================== + +* `Doc` is now an instance of `Monoid`. + +* Add `renderOneLine` function. + +* Add `IsString` instances. + +* Make `SimpleDoc` an instance of `Show` for convenience. + +* Make the `Show` instance for `Doc` match the documentation. + +1.0.0.0 (2012-05-22) +==================== + +* Initial version, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wl-pprint-text-1.1.0.4/README.md new/wl-pprint-text-1.1.1.0/README.md --- old/wl-pprint-text-1.1.0.4/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/wl-pprint-text-1.1.1.0/README.md 2017-01-26 12:56:06.000000000 +0100 @@ -0,0 +1,8 @@ +wl-pprint-text +============== + +[](https://hackage.haskell.org/package/wl-pprint-text) [](https://travis-ci.org/ivan-m/wl-pprint-text) + +A clone of [wl-pprint](http://hackage.haskell.org/package/wl-pprint) +for use with the [text](http://hackage.haskell.org/package/text) +library (with some improved handling of whitespace). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wl-pprint-text-1.1.0.4/Text/PrettyPrint/Leijen/Text/Monadic.hs new/wl-pprint-text-1.1.1.0/Text/PrettyPrint/Leijen/Text/Monadic.hs --- old/wl-pprint-text-1.1.0.4/Text/PrettyPrint/Leijen/Text/Monadic.hs 2015-04-06 14:24:45.000000000 +0200 +++ new/wl-pprint-text-1.1.1.0/Text/PrettyPrint/Leijen/Text/Monadic.hs 2017-01-26 12:56:06.000000000 +0100 @@ -21,7 +21,7 @@ Doc, -- putDoc, hPutDoc, -- * Basic combinators - empty, char, text, (<>), nest, line, linebreak, group, softline, + empty, char, text, textStrict, (<>), nest, line, linebreak, group, softline, softbreak, spacebreak, -- * Alignment @@ -55,7 +55,7 @@ squote, dquote, semi, colon, comma, space, dot, backslash, equals, -- * Primitive type documents - string, int, integer, float, double, rational, bool, + string, stringStrict, int, integer, float, double, rational, bool, -- * Position-based combinators column, nesting, width, @@ -65,28 +65,29 @@ -- * Rendering SimpleDoc(..), renderPretty, renderCompact, renderOneLine, - displayB, displayT, displayIO, putDoc, hPutDoc + displayB, displayT, displayTStrict, displayIO, putDoc, hPutDoc ) where -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 710 -import Prelude hiding ((<$>)) -#endif +import Prelude () +import Prelude.Compat hiding ((<$>)) + import Text.PrettyPrint.Leijen.Text (Doc, Pretty (..), SimpleDoc (..), - displayB, displayIO, displayT, + displayB, displayIO, displayT, displayTStrict, hPutDoc, putDoc, renderCompact, renderOneLine, renderPretty) import qualified Text.PrettyPrint.Leijen.Text as PP -import Control.Monad (liftM, liftM2, liftM3, liftM4) +import Control.Applicative (liftA2, liftA3) import Data.String (IsString (..)) +import qualified Data.Text as TS import Data.Text.Lazy (Text) infixr 5 </>,<//>,<$>,<$$> infixr 6 <>,<+>,<++> -instance Monad m => IsString (m Doc) where +instance (Applicative m) => IsString (m Doc) where fromString = string . fromString ----------------------------------------------------------- @@ -96,24 +97,24 @@ -- horizontally if that fits the page. Otherwise they are aligned -- vertically. All comma separators are put in front of the -- elements. -list :: (Monad m) => m [Doc] -> m Doc -list = liftM PP.list +list :: (Functor m) => m [Doc] -> m Doc +list = fmap PP.list -- | The document @(tupled xs)@ comma separates the documents @xs@ and -- encloses them in parenthesis. The documents are rendered -- horizontally if that fits the page. Otherwise they are aligned -- vertically. All comma separators are put in front of the -- elements. -tupled :: (Monad m) => m [Doc] -> m Doc -tupled = liftM PP.tupled +tupled :: (Functor m) => m [Doc] -> m Doc +tupled = fmap PP.tupled -- | The document @(semiBraces xs)@ separates the documents @xs@ with -- semi colons and encloses them in braces. The documents are -- rendered horizontally if that fits the page. Otherwise they are -- aligned vertically. All semi colons are put in front of the -- elements. -semiBraces :: (Monad m) => m [Doc] -> m Doc -semiBraces = liftM PP.semiBraces +semiBraces :: (Functor m) => m [Doc] -> m Doc +semiBraces = fmap PP.semiBraces -- | The document @(encloseSep l r sep xs)@ concatenates the documents -- @xs@ separated by @sep@ and encloses the resulting document by @@ -138,8 +139,8 @@ -- ,200 -- ,3000] -- @ -encloseSep :: (Monad m) => m Doc -> m Doc -> m Doc -> m [Doc] -> m Doc -encloseSep = liftM4 PP.encloseSep +encloseSep :: (Applicative m) => m Doc -> m Doc -> m Doc -> m [Doc] -> m Doc +encloseSep a b c d = liftA3 PP.encloseSep a b c <*> d -- | @(punctuate p xs)@ concatenates all documents in @xs@ with -- document @p@ except for the last document. @@ -164,16 +165,16 @@ -- -- (If you want put the commas in front of their elements instead of -- at the end, you should use 'tupled' or, in general, 'encloseSep'.) -punctuate :: (Monad m) => m Doc -> m [Doc] -> m [Doc] -punctuate = liftM2 PP.punctuate +punctuate :: (Applicative m) => m Doc -> m [Doc] -> m [Doc] +punctuate = liftA2 PP.punctuate -- | The document @(sep xs)@ concatenates all documents @xs@ either -- horizontally with @(\<+\>)@, if it fits the page, or vertically -- with @(\<$\>)@. -- -- > sep xs = group (vsep xs) -sep :: (Monad m) => m [Doc] -> m Doc -sep = liftM PP.sep +sep :: (Functor m) => m [Doc] -> m Doc +sep = fmap PP.sep -- | The document @(fillSep xs)@ concatenates documents @xs@ -- horizontally with @(\<+\>)@ as long as its fits the page, then @@ -181,13 +182,13 @@ -- @xs@. -- -- > fillSep xs = foldr (</>) empty xs -fillSep :: (Monad m) => m [Doc] -> m Doc -fillSep = liftM PP.fillSep +fillSep :: (Functor m) => m [Doc] -> m Doc +fillSep = fmap PP.fillSep -- | The document @(hsep xs)@ concatenates all documents @xs@ -- horizontally with @(\<+\>)@. -hsep :: (Monad m) => m [Doc] -> m Doc -hsep = liftM PP.hsep +hsep :: (Functor m) => m [Doc] -> m Doc +hsep = fmap PP.hsep -- | The document @(vsep xs)@ concatenates all documents @xs@ -- vertically with @(\<$\>)@. If a 'group' undoes the line breaks @@ -219,16 +220,16 @@ -- lay -- out -- @ -vsep :: (Monad m) => m [Doc] -> m Doc -vsep = liftM PP.vsep +vsep :: (Functor m) => m [Doc] -> m Doc +vsep = fmap PP.vsep -- | The document @(cat xs)@ concatenates all documents @xs@ either -- horizontally with @(\<\>)@, if it fits the page, or vertically -- with @(\<$$\>)@. -- -- > cat xs = group (vcat xs) -cat :: (Monad m) => m [Doc] -> m Doc -cat = liftM PP.cat +cat :: (Functor m) => m [Doc] -> m Doc +cat = fmap PP.cat -- | The document @(fillCat xs)@ concatenates documents @xs@ -- horizontally with @(\<\>)@ as long as its fits the page, then @@ -236,181 +237,181 @@ -- in @xs@. -- -- > fillCat xs = foldr (<//>) empty xs -fillCat :: (Monad m) => m [Doc] -> m Doc -fillCat = liftM PP.fillCat +fillCat :: (Functor m) => m [Doc] -> m Doc +fillCat = fmap PP.fillCat -- | The document @(hcat xs)@ concatenates all documents @xs@ -- horizontally with @(\<\>)@. -hcat :: (Monad m) => m [Doc] -> m Doc -hcat = liftM PP.hcat +hcat :: (Functor m) => m [Doc] -> m Doc +hcat = fmap PP.hcat -- | The document @(vcat xs)@ concatenates all documents @xs@ -- vertically with @(\<$$\>)@. If a 'group' undoes the line breaks -- inserted by @vcat@, all documents are directly concatenated. -vcat :: (Monad m) => m [Doc] -> m Doc -vcat = liftM PP.vcat +vcat :: (Functor m) => m [Doc] -> m Doc +vcat = fmap PP.vcat -- | The document @(x \<\> y)@ concatenates document @x@ and document -- @y@. It is an associative operation having 'empty' as a left and -- right unit. (infixr 6) -(<>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<>) = liftM2 (PP.<>) +(<>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<>) = liftA2 (PP.<>) -- | The document @(x \<+\> y)@ concatenates document @x@ and @y@ with -- a 'space' in between. (infixr 6) -(<+>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<+>) = liftM2 (PP.<+>) +(<+>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<+>) = liftA2 (PP.<+>) -- | The document @(x \<++\> y)@ concatenates document @x@ and @y@ with -- a 'spacebreak' in between. (infixr 6) -(<++>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<++>) = liftM2 (PP.<++>) +(<++>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<++>) = liftA2 (PP.<++>) -- | The document @(x \<\/\> y)@ concatenates document @x@ and @y@ -- with a 'softline' in between. This effectively puts @x@ and @y@ -- either next to each other (with a @space@ in between) or -- underneath each other. (infixr 5) -(</>) :: (Monad m) => m Doc -> m Doc -> m Doc -(</>) = liftM2 (PP.</>) +(</>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(</>) = liftA2 (PP.</>) -- | The document @(x \<\/\/\> y)@ concatenates document @x@ and @y@ -- with a 'softbreak' in between. This effectively puts @x@ and @y@ -- either right next to each other or underneath each other. (infixr -- 5) -(<//>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<//>) = liftM2 (PP.<//>) +(<//>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<//>) = liftA2 (PP.<//>) -- | The document @(x \<$\> y)@ concatenates document @x@ and @y@ with -- a 'line' in between. (infixr 5) -(<$>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<$>) = liftM2 (PP.<$>) +(<$>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<$>) = liftA2 (PP.<$>) -- | The document @(x \<$$\> y)@ concatenates document @x@ and @y@ -- with a 'linebreak' in between. (infixr 5) -(<$$>) :: (Monad m) => m Doc -> m Doc -> m Doc -(<$$>) = liftM2 (PP.<$$>) +(<$$>) :: (Applicative m) => m Doc -> m Doc -> m Doc +(<$$>) = liftA2 (PP.<$$>) -- | The document @softline@ behaves like 'space' if the resulting -- output fits the page, otherwise it behaves like 'line'. -softline :: (Monad m) => m Doc -softline = return PP.softline +softline :: (Applicative m) => m Doc +softline = pure PP.softline -- | The document @softbreak@ behaves like 'empty' if the resulting -- output fits the page, otherwise it behaves like 'line'. -softbreak :: (Monad m) => m Doc -softbreak = return PP.softbreak +softbreak :: (Applicative m) => m Doc +softbreak = pure PP.softbreak -- | The document @spacebreak@ behaves like 'space' when rendered normally -- but like 'empty' when using 'renderCompact' or 'renderOneLine'. -spacebreak :: (Monad m) => m Doc -spacebreak = return PP.spacebreak +spacebreak :: (Applicative m) => m Doc +spacebreak = pure PP.spacebreak -- | Document @(squotes x)@ encloses document @x@ with single quotes -- \"'\". -squotes :: (Monad m) => m Doc -> m Doc -squotes = liftM PP.squotes +squotes :: (Functor m) => m Doc -> m Doc +squotes = fmap PP.squotes -- | Document @(dquotes x)@ encloses document @x@ with double quotes -- '\"'. -dquotes :: (Monad m) => m Doc -> m Doc -dquotes = liftM PP.dquotes +dquotes :: (Functor m) => m Doc -> m Doc +dquotes = fmap PP.dquotes -- | Document @(braces x)@ encloses document @x@ in braces, \"{\" and -- \"}\". -braces :: (Monad m) => m Doc -> m Doc -braces = liftM PP.braces +braces :: (Functor m) => m Doc -> m Doc +braces = fmap PP.braces -- | Document @(parens x)@ encloses document @x@ in parenthesis, \"(\" -- and \")\". -parens :: (Monad m) => m Doc -> m Doc -parens = liftM PP.parens +parens :: (Functor m) => m Doc -> m Doc +parens = fmap PP.parens -- | Document @(angles x)@ encloses document @x@ in angles, \"\<\" and -- \"\>\". -angles :: (Monad m) => m Doc -> m Doc -angles = liftM PP.angles +angles :: (Functor m) => m Doc -> m Doc +angles = fmap PP.angles -- | Document @(brackets x)@ encloses document @x@ in square brackets, -- \"[\" and \"]\". -brackets :: (Monad m) => m Doc -> m Doc -brackets = liftM PP.brackets +brackets :: (Functor m) => m Doc -> m Doc +brackets = fmap PP.brackets -- | The document @(enclose l r x)@ encloses document @x@ between -- documents @l@ and @r@ using @(\<\>)@. -- -- > enclose l r x = l <> x <> r -enclose :: (Monad m) => m Doc -> m Doc -> m Doc -> m Doc -enclose = liftM3 PP.enclose +enclose :: (Applicative m) => m Doc -> m Doc -> m Doc -> m Doc +enclose = liftA3 PP.enclose -- | The document @lparen@ contains a left parenthesis, \"(\". -lparen :: (Monad m) => m Doc -lparen = return PP.lparen +lparen :: (Applicative m) => m Doc +lparen = pure PP.lparen -- | The document @rparen@ contains a right parenthesis, \")\". -rparen :: (Monad m) => m Doc -rparen = return PP.rparen +rparen :: (Applicative m) => m Doc +rparen = pure PP.rparen -- | The document @langle@ contains a left angle, \"\<\". -langle :: (Monad m) => m Doc -langle = return PP.langle +langle :: (Applicative m) => m Doc +langle = pure PP.langle -- | The document @rangle@ contains a right angle, \">\". -rangle :: (Monad m) => m Doc -rangle = return PP.rangle +rangle :: (Applicative m) => m Doc +rangle = pure PP.rangle -- | The document @lbrace@ contains a left brace, \"{\". -lbrace :: (Monad m) => m Doc -lbrace = return PP.lbrace +lbrace :: (Applicative m) => m Doc +lbrace = pure PP.lbrace -- | The document @rbrace@ contains a right brace, \"}\". -rbrace :: (Monad m) => m Doc -rbrace = return PP.rbrace +rbrace :: (Applicative m) => m Doc +rbrace = pure PP.rbrace -- | The document @lbracket@ contains a left square bracket, \"[\". -lbracket :: (Monad m) => m Doc -lbracket = return PP.lbracket +lbracket :: (Applicative m) => m Doc +lbracket = pure PP.lbracket -- | The document @rbracket@ contains a right square bracket, \"]\". -rbracket :: (Monad m) => m Doc -rbracket = return PP.rbracket +rbracket :: (Applicative m) => m Doc +rbracket = pure PP.rbracket -- | The document @squote@ contains a single quote, \"'\". -squote :: (Monad m) => m Doc -squote = return PP.squote +squote :: (Applicative m) => m Doc +squote = pure PP.squote -- | The document @dquote@ contains a double quote, '\"'. -dquote :: (Monad m) => m Doc -dquote = return PP.dquote +dquote :: (Applicative m) => m Doc +dquote = pure PP.dquote -- | The document @semi@ contains a semi colon, \";\". -semi :: (Monad m) => m Doc -semi = return PP.semi +semi :: (Applicative m) => m Doc +semi = pure PP.semi -- | The document @colon@ contains a colon, \":\". -colon :: (Monad m) => m Doc -colon = return PP.colon +colon :: (Applicative m) => m Doc +colon = pure PP.colon -- | The document @comma@ contains a comma, \",\". -comma :: (Monad m) => m Doc -comma = return PP.comma +comma :: (Applicative m) => m Doc +comma = pure PP.comma -- | The document @space@ contains a single space, \" \". -- -- > x <+> y = x <> space <> y -space :: (Monad m) => m Doc -space = return PP.space +space :: (Applicative m) => m Doc +space = pure PP.space -- | The document @dot@ contains a single dot, \".\". -dot :: (Monad m) => m Doc -dot = return PP.dot +dot :: (Applicative m) => m Doc +dot = pure PP.dot -- | The document @backslash@ contains a back slash, \"\\\". -backslash :: (Monad m) => m Doc -backslash = return PP.backslash +backslash :: (Applicative m) => m Doc +backslash = pure PP.backslash -- | The document @equals@ contains an equal sign, \"=\". -equals :: (Monad m) => m Doc -equals = return PP.equals +equals :: (Applicative m) => m Doc +equals = pure PP.equals ----------------------------------------------------------- -- Combinators for prelude types @@ -420,45 +421,48 @@ -- using @line@ for newline characters and @char@ for all other -- characters. It is used instead of 'text' whenever the text -- contains newline characters. -string :: (Monad m) => Text -> m Doc -string = return . PP.string +string :: (Applicative m) => Text -> m Doc +string = pure . PP.string + +stringStrict :: Monad m => TS.Text -> m Doc +stringStrict = return . PP.stringStrict -- | The document @(bool b)@ shows the literal boolean @b@ using -- 'text'. -bool :: (Monad m) => Bool -> m Doc -bool = return . PP.bool +bool :: (Applicative m) => Bool -> m Doc +bool = pure . PP.bool -- | The document @(int i)@ shows the literal integer @i@ using -- 'text'. -int :: (Monad m) => Int -> m Doc -int = return . PP.int +int :: (Applicative m) => Int -> m Doc +int = pure . PP.int -- | The document @(integer i)@ shows the literal integer @i@ using -- 'text'. -integer :: (Monad m) => Integer -> m Doc -integer = return . PP.integer +integer :: (Applicative m) => Integer -> m Doc +integer = pure . PP.integer -- | The document @(float f)@ shows the literal float @f@ using -- 'text'. -float :: (Monad m) => Float -> m Doc -float = return . PP.float +float :: (Applicative m) => Float -> m Doc +float = pure . PP.float -- | The document @(double d)@ shows the literal double @d@ using -- 'text'. -double :: (Monad m) => Double -> m Doc -double = return . PP.double +double :: (Applicative m) => Double -> m Doc +double = pure . PP.double -- | The document @(rational r)@ shows the literal rational @r@ using -- 'text'. -rational :: (Monad m) => Rational -> m Doc -rational = return . PP.rational +rational :: (Applicative m) => Rational -> m Doc +rational = pure . PP.rational -- | A monadic version of 'pretty'; this is to allow you to use the -- 'Pretty' class without having to create extra instances. -- Alternatively, you may wish to make a variant of 'Pretty' using -- the actual 'Monad' to be used. -prettyM :: (Pretty a, Monad m) => a -> m Doc -prettyM = return . pretty +prettyM :: (Pretty a, Applicative m) => a -> m Doc +prettyM = pure . pretty -- | The document @(fill i x)@ renders document @x@. It then appends -- @space@s until the width is equal to @i@. If the width of @x@ is @@ -482,12 +486,12 @@ -- nest :: Int -> Doc -> Doc -- linebreak :: Doc -- @ -fill :: (Monad m) => Int -> m Doc -> m Doc -fill = liftM . PP.fill +fill :: (Functor m) => Int -> m Doc -> m Doc +fill = fmap . PP.fill -width :: (Monad m) => m Doc -> m (Int -> Doc) -> m Doc -width = liftM2 PP.width +width :: (Applicative m) => m Doc -> m (Int -> Doc) -> m Doc +width = liftA2 PP.width -- | The document @(fillBreak i x)@ first renders document @x@. It -- then appends @space@s until the width is equal to @i@. If the @@ -507,8 +511,8 @@ -- linebreak -- :: Doc -- @ -fillBreak :: (Monad m) => Int -> m Doc -> m Doc -fillBreak = liftM . PP.fillBreak +fillBreak :: (Functor m) => Int -> m Doc -> m Doc +fillBreak = fmap . PP.fillBreak -- | The document @(indent i x)@ indents document @x@ with @i@ spaces. -- @@ -523,8 +527,8 @@ -- indents these -- words ! -- @ -indent :: (Monad m) => Int -> m Doc -> m Doc -indent = liftM . PP.indent +indent :: (Functor m) => Int -> m Doc -> m Doc +indent = fmap . PP.indent -- | The hang combinator implements hanging indentation. The document -- @(hang i x)@ renders document @x@ with a nesting level set to the @@ -545,8 +549,8 @@ -- The @hang@ combinator is implemented as: -- -- > hang i x = align (nest i x) -hang :: (Monad m) => Int -> m Doc -> m Doc -hang = liftM . PP.hang +hang :: (Functor m) => Int -> m Doc -> m Doc +hang = fmap . PP.hang -- | The document @(align x)@ renders document @x@ with the nesting -- level set to the current column. It is used for example to @@ -565,40 +569,43 @@ -- hi nice -- world -- @ -align :: (Monad m) => m Doc -> m Doc -align = liftM PP.align +align :: (Functor m) => m Doc -> m Doc +align = fmap PP.align -- | The empty document is, indeed, empty. Although @empty@ has no -- content, it does have a \'height\' of 1 and behaves exactly like -- @(text \"\")@ (and is therefore not a unit of @\<$\>@). -empty :: (Monad m) => m Doc -empty = return PP.empty +empty :: (Applicative m) => m Doc +empty = pure PP.empty -- | The document @(char c)@ contains the literal character @c@. The -- character shouldn't be a newline (@'\n'@), the function 'line' -- should be used for line breaks. -char :: (Monad m) => Char -> m Doc -char = return . PP.char +char :: (Applicative m) => Char -> m Doc +char = pure . PP.char -- | The document @(text s)@ contains the literal string @s@. The -- string shouldn't contain any newline (@'\n'@) characters. If the -- string contains newline characters, the function 'string' should -- be used. -text :: (Monad m) => Text -> m Doc -text = return . PP.text +text :: (Applicative m) => Text -> m Doc +text = pure . PP.text + +textStrict :: Monad m => TS.Text -> m Doc +textStrict = return . PP.textStrict -- | The @line@ document advances to the next line and indents to the -- current nesting level. Document @line@ behaves like @(text \" -- \")@ if the line break is undone by 'group' or if rendered with -- 'renderOneLine'. -line :: (Monad m) => m Doc -line = return PP.line +line :: (Applicative m) => m Doc +line = pure PP.line -- | The @linebreak@ document advances to the next line and indents to -- the current nesting level. Document @linebreak@ behaves like -- 'empty' if the line break is undone by 'group'. -linebreak :: (Monad m) => m Doc -linebreak = return PP.linebreak +linebreak :: (Applicative m) => m Doc +linebreak = pure PP.linebreak -- | The document @(nest i x)@ renders document @x@ with the current -- indentation level increased by @i@ (See also 'hang', 'align' and @@ -613,22 +620,22 @@ -- world -- ! -- @ -nest :: (Monad m) => Int -> m Doc -> m Doc -nest = liftM . PP.nest +nest :: (Functor m) => Int -> m Doc -> m Doc +nest = fmap . PP.nest -- | Specifies how to create the document based upon which column it is in. -column :: (Monad m) => m (Int -> Doc) -> m Doc -column = liftM PP.column +column :: (Functor m) => m (Int -> Doc) -> m Doc +column = fmap PP.column -- | Specifies how to nest the document based upon which column it is -- being nested in. -nesting :: (Monad m) => m (Int -> Doc) -> m Doc -nesting = liftM PP.nesting +nesting :: (Functor m) => m (Int -> Doc) -> m Doc +nesting = fmap PP.nesting -- | The @group@ combinator is used to specify alternative -- layouts. The document @(group x)@ undoes all line breaks in -- document @x@. The resulting line is added to the current line if -- that fits the page. Otherwise, the document @x@ is rendered -- without any changes. -group :: (Monad m) => m Doc -> m Doc -group = liftM PP.group +group :: (Functor m) => m Doc -> m Doc +group = fmap PP.group diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wl-pprint-text-1.1.0.4/Text/PrettyPrint/Leijen/Text.hs new/wl-pprint-text-1.1.1.0/Text/PrettyPrint/Leijen/Text.hs --- old/wl-pprint-text-1.1.0.4/Text/PrettyPrint/Leijen/Text.hs 2015-04-06 14:24:45.000000000 +0200 +++ new/wl-pprint-text-1.1.1.0/Text/PrettyPrint/Leijen/Text.hs 2017-01-26 12:56:06.000000000 +0100 @@ -70,8 +70,8 @@ Doc, -- * Basic combinators - empty, char, text, (<>), nest, line, linebreak, group, softline, - softbreak, spacebreak, + empty, isEmpty, char, text, textStrict, (<>), nest, line, linebreak, group, + softline, softbreak, spacebreak, -- * Alignment -- @@ -104,7 +104,7 @@ squote, dquote, semi, colon, comma, space, dot, backslash, equals, -- * Primitive type documents - string, int, integer, float, double, rational, bool, + string, stringStrict, int, integer, float, double, rational, bool, -- * Position-based combinators column, nesting, width, @@ -114,28 +114,34 @@ -- * Rendering SimpleDoc(..), renderPretty, renderCompact, renderOneLine, - displayB, displayT, displayIO, putDoc, hPutDoc + displayB, displayT, displayTStrict, displayIO, putDoc, hPutDoc ) where -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 710 -import Prelude hiding ((<$>)) -#endif +import Prelude () +import Prelude.Compat hiding ((<$>)) -import Data.String (IsString (..)) +import Data.String (IsString(..)) import System.IO (Handle, hPutChar, stdout) import Data.Int (Int64) -import Data.Monoid (Monoid (..)) +import Data.List (intersperse) +import Data.Monoid (Monoid(..)) +import qualified Data.Text as TS import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as T import Data.Text.Lazy.Builder (Builder) import qualified Data.Text.Lazy.Builder as B import qualified Data.Text.Lazy.IO as T +#if MIN_VERSION_base (4,9,0) +import Data.Semigroup (Semigroup(..)) +#else +import Data.Monoid ((<>)) +#endif infixr 5 </>,<//>,<$>,<$$> -infixr 6 <>,<+>,<++> +infixr 6 <+>,<++> ----------------------------------------------------------- @@ -227,8 +233,8 @@ -- (If you want put the commas in front of their elements instead of -- at the end, you should use 'tupled' or, in general, 'encloseSep'.) punctuate :: Doc -> [Doc] -> [Doc] -punctuate _ [] = [] -punctuate _ [d] = [d] +punctuate _ [] = [] +punctuate _ [d] = [d] punctuate p (d:ds) = (d <> p) : punctuate p ds @@ -324,12 +330,6 @@ fold _ [] = empty fold f ds = foldr1 f ds --- | The document @(x \<\> y)@ concatenates document @x@ and document --- @y@. It is an associative operation having 'empty' as a left and --- right unit. (infixr 6) -(<>) :: Doc -> Doc -> Doc -x <> y = x `beside` y - -- | The document @(x \<+\> y)@ concatenates document @x@ and @y@ with -- a 'space' in between. (infixr 6) (<+>) :: Doc -> Doc -> Doc @@ -516,41 +516,40 @@ -- characters. It is used instead of 'text' whenever the text -- contains newline characters. string :: Text -> Doc -string str = case T.uncons str of - Nothing -> empty - Just ('\n',str') -> line <> string str' - _ -> case (T.span (/='\n') str) of - (xs,ys) -> text xs <> string ys +string = mconcat . intersperse line . map text . T.lines + +stringStrict :: TS.Text -> Doc +stringStrict = mconcat . intersperse line . map textStrict . TS.lines -- | The document @(bool b)@ shows the literal boolean @b@ using -- 'text'. bool :: Bool -> Doc -bool b = text' b +bool = text' -- | The document @(int i)@ shows the literal integer @i@ using -- 'text'. int :: Int -> Doc -int i = text' i +int = text' -- | The document @(integer i)@ shows the literal integer @i@ using -- 'text'. integer :: Integer -> Doc -integer i = text' i +integer = text' -- | The document @(float f)@ shows the literal float @f@ using -- 'text'. float :: Float -> Doc -float f = text' f +float = text' -- | The document @(double d)@ shows the literal double @d@ using -- 'text'. double :: Double -> Doc -double d = text' d +double = text' -- | The document @(rational r)@ shows the literal rational @r@ using -- 'text'. rational :: Rational -> Doc -rational r = text' r +rational = text' text' :: (Show a) => a -> Doc text' = text . T.pack . show @@ -577,40 +576,43 @@ instance Pretty Text where pretty = string +instance Pretty TS.Text where + pretty = stringStrict + instance Pretty () where pretty () = text' () instance Pretty Bool where - pretty b = bool b + pretty = bool instance Pretty Char where - pretty c = char c + pretty = char - prettyList s = string $ T.pack s + prettyList = string . T.pack instance Pretty Int where - pretty i = int i + pretty = int instance Pretty Integer where - pretty i = integer i + pretty = integer instance Pretty Float where - pretty f = float f + pretty = float instance Pretty Double where - pretty d = double d + pretty = double --instance Pretty Rational where -- pretty r = rational r -instance (Pretty a,Pretty b) => Pretty (a,b) where +instance (Pretty a, Pretty b) => Pretty (a,b) where pretty (x,y) = tupled [pretty x, pretty y] -instance (Pretty a,Pretty b,Pretty c) => Pretty (a,b,c) where +instance (Pretty a, Pretty b, Pretty c) => Pretty (a,b,c) where pretty (x,y,z)= tupled [pretty x, pretty y, pretty z] instance Pretty a => Pretty (Maybe a) where - pretty Nothing = empty + pretty Nothing = empty pretty (Just x) = pretty x @@ -638,7 +640,7 @@ -- @ fillBreak :: Int -> Doc -> Doc fillBreak f x = width x (\w -> - if (w > f) + if w > f then nest f linebreak else spaced (f - w) ) @@ -668,7 +670,7 @@ -- @ fill :: Int -> Doc -> Doc fill f d = width d (\w -> - if (w >= f) + if w >= f then empty else spaced (f - w) ) @@ -773,6 +775,14 @@ instance IsString Doc where fromString = string . T.pack +-- | In particular, note that the document @(x '<>' y)@ concatenates +-- document @x@ and document @y@. It is an associative operation +-- having 'empty' as a left and right unit. (infixr 6) +#if MIN_VERSION_base (4,9,0) +instance Semigroup Doc where + (<>) = beside + +#endif instance Monoid Doc where mempty = empty mappend = beside @@ -796,6 +806,11 @@ empty :: Doc empty = Empty +-- | Determine if the document is empty or not. +isEmpty :: Doc -> Bool +isEmpty Empty = True +isEmpty _ = False + -- | The document @(char c)@ contains the literal character @c@. The -- character shouldn't be a newline (@'\n'@), the function 'line' -- should be used for line breaks. @@ -812,6 +827,11 @@ | T.null s = Empty | otherwise = Text (T.length s) (B.fromLazyText s) +textStrict :: TS.Text -> Doc +textStrict s + | TS.null s = Empty + | otherwise = Text (fromIntegral $ TS.length s) (B.fromText s) + -- | The @line@ document advances to the next line and indents to the -- current nesting level. Document @line@ behaves like @(text \" -- \")@ if the line break is undone by 'group' or if rendered with @@ -1011,14 +1031,16 @@ displayT :: SimpleDoc -> Text displayT = B.toLazyText . displayB +displayTStrict :: SimpleDoc -> TS.Text +displayTStrict = T.toStrict . displayT + -- | @(displayIO handle simpleDoc)@ writes @simpleDoc@ to the -- file handle @handle@. This function is used for example by -- 'hPutDoc': -- -- > hPutDoc handle doc = displayIO handle (renderPretty 0.4 100 doc) displayIO :: Handle -> SimpleDoc -> IO () -displayIO handle simpleDoc - = display simpleDoc +displayIO handle = display where display SEmpty = return () display (SChar c x) = hPutChar handle c >> display x @@ -1051,7 +1073,7 @@ -- hello world -- @ putDoc :: Doc -> IO () -putDoc doc = hPutDoc stdout doc +putDoc = hPutDoc stdout -- | @(hPutDoc handle doc)@ pretty prints document @doc@ to the file -- handle @handle@ with a page width of 100 characters and a ribbon diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wl-pprint-text-1.1.0.4/wl-pprint-text.cabal new/wl-pprint-text-1.1.1.0/wl-pprint-text.cabal --- old/wl-pprint-text-1.1.0.4/wl-pprint-text.cabal 2015-04-06 14:24:45.000000000 +0200 +++ new/wl-pprint-text-1.1.1.0/wl-pprint-text.cabal 2017-01-26 12:56:06.000000000 +0100 @@ -1,5 +1,5 @@ Name: wl-pprint-text -Version: 1.1.0.4 +Version: 1.1.1.0 Synopsis: A Wadler/Leijen Pretty Printer for Text values Description: A clone of wl-pprint for use with the text library. License: BSD3 @@ -9,14 +9,19 @@ Copyright: 2007 Daan Leijen, 2010 Ivan Lazar Miljenovic Category: Text Build-type: Simple +Tested-With: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, + GHC == 7.10.2, GHC == 8.0.1, GHC == 8.1.* Cabal-version: >=1.6 +Extra-Source-Files: Changelog.md + README.md Source-Repository head type: git - location: git://github.com/ivan-m/wl-pprint-text.git + location: https://github.com/ivan-m/wl-pprint-text.git Library Exposed-modules: Text.PrettyPrint.Leijen.Text, Text.PrettyPrint.Leijen.Text.Monadic - Build-depends: base < 5, + Build-depends: base >= 4.5.0.0 && < 5, + base-compat >= 0.9 && < 0.10, text >= 0.11.0.0 && < 1.3.0.0
participants (1)
-
root@hilbertn.suse.de