packages feed

core-text 0.2.0.0 → 0.2.2.1

raw patch · 6 files changed

+78/−50 lines, 6 filesdep ~prettyprinterdep ~text-shortPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: prettyprinter, text-short

API changes (from Hackage documentation)

+ Core.Text.Rope: singletonRope :: Char -> Rope
+ Core.Text.Utilities: renderNoAnsi :: Render α => Int -> α -> Rope

Files

− LICENCE
@@ -1,32 +0,0 @@-Opinionated Haskell Interoperability--Copyright © 2018-2019 Operational Dynamics Consulting, Pty Ltd and Others-All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:--    1. Redistributions of source code must retain the above copyright-       notice, this list of conditions and the following disclaimer.--    2. Redistributions in binary form must reproduce the above-       copyright notice, this list of conditions and the following-       disclaimer in the documentation and/or other materials provided-       with the distribution.-      -    3. Neither the name of the project nor the names of its contributors-       may be used to endorse or promote products derived from this -       software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ LICENSE view
@@ -0,0 +1,32 @@+Opinionated Haskell Interoperability++Copyright © 2018-2019 Operational Dynamics Consulting, Pty Ltd and Others+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++    1. Redistributions of source code must retain the above copyright+       notice, this list of conditions and the following disclaimer.++    2. Redistributions in binary form must reproduce the above+       copyright notice, this list of conditions and the following+       disclaimer in the documentation and/or other materials provided+       with the distribution.+      +    3. Neither the name of the project nor the names of its contributors+       may be used to endorse or promote products derived from this +       software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
core-text.cabal view
@@ -1,8 +1,8 @@ cabal-version: 1.12 name: core-text-version: 0.2.0.0+version: 0.2.2.1 license: BSD3-license-file: LICENCE+license-file: LICENSE copyright: © 2018-2019 Operational Dynamics Consulting Pty Ltd, and Others maintainer: Andrew Cowie <andrew@operationaldynamics.com> author: Andrew Cowie <andrew@operationaldynamics.com>@@ -10,12 +10,15 @@ tested-with: ghc ==8.6.5 homepage: https://github.com/oprdyn/unbeliever#readme bug-reports: https://github.com/oprdyn/unbeliever/issues-synopsis: A text type based on a finger tree over UTF-8 fragments+synopsis: A rope type based on a finger tree over UTF-8 fragments description:-    A data type for text, built as a finger tree over UTF-8 text fragments.+    A rope data type for text, built as a finger tree over UTF-8 text+    fragments. The package also includes utiltiy functions for breaking and+    re-wrapping lines, conveniences for pretty printing and colourizing+    terminal output, and a simple mechanism for multi-line Rope literals.     .-    The main type and its usage are described at "Core.Text.Rope" in this-    package.+    The main @Rope@ type and its usage are described at "Core.Text.Rope" in+    this package.     .     This is part of a library intended to ease interoperability and assist in     building command-line programs, both tools and longer-running daemons.@@ -47,8 +50,8 @@         deepseq >=1.4.4.0 && <1.5,         fingertree >=0.1.4.2 && <0.2,         hashable >=1.2.7.0 && <1.3,-        prettyprinter >=1.2.1 && <1.3,+        prettyprinter >=1.2.1.1 && <1.3,         prettyprinter-ansi-terminal >=1.1.1.2 && <1.2,         template-haskell >=2.14.0.0 && <2.15,         text >=1.2.3.1 && <1.3,-        text-short >=0.1.2 && <0.2+        text-short >=0.1.3 && <0.2
lib/Core/Text/Bytes.hs view
@@ -54,7 +54,7 @@ {-| A block of data in binary form. -}-data Bytes+newtype Bytes     = StrictBytes B.ByteString     deriving (Show, Eq, Ord, Generic) 
lib/Core/Text/Rope.hs view
@@ -75,6 +75,7 @@     ( {-* Rope type -}       Rope     , emptyRope+    , singletonRope     , widthRope     , splitRope     , insertRope@@ -108,7 +109,7 @@     , fromText) import Data.Text.Prettyprint.Doc (Pretty(..), emptyDoc) import qualified Data.Text.Short as S (ShortText, length, any, null-    , fromText, toText, fromByteString, pack, unpack+    , fromText, toText, fromByteString, pack, unpack, singleton     , append, empty, toBuilder, splitAt) import qualified Data.Text.Short.Unsafe as S (fromByteStringUnsafe) import GHC.Generics (Generic)@@ -151,7 +152,7 @@  Output to a @Handle@ can be done efficiently with 'hWrite'. -}-data Rope+newtype Rope     = Rope (F.FingerTree Width S.ShortText)     deriving Generic @@ -233,6 +234,12 @@ {-# INLINABLE emptyRope #-}  {-|+A 'Rope' with but a single character.+-}+singletonRope :: Char -> Rope+singletonRope = Rope . F.singleton . S.singleton++{-| Get the length of this text, in characters. -} widthRope :: Rope -> Int@@ -466,9 +473,11 @@ 'Data.ByteString.Builder.Builder' to the 'System.IO.Handle''s output buffer in one go. -If you're working in the 'Core.Program.Execute.Program' monad, then-'Core.Program.Execute.write' provides an efficient way to write a @Rope@ to-@stdout@.+If you're working in the+<https://hackage.haskell.org/package/core-program/docs/Core-Program-Execute.html#t:Program Program>+monad, then+<https://hackage.haskell.org/package/core-program/docs/Core-Program-Logging.html#v:write write>+provides an efficient way to write a @Rope@ to @stdout@. -} hWrite :: Handle -> Rope -> IO () hWrite handle (Rope x) = B.hPutBuilder handle (foldr j mempty x)
lib/Core/Text/Utilities.hs view
@@ -16,6 +16,7 @@       {-* Pretty printing -}       Render(..)     , render+    , renderNoAnsi       {-* Helpers -}     , indefinite     , breakWords@@ -45,7 +46,7 @@ import qualified Data.Text.Short as S (ShortText, uncons, toText, replicate     , singleton) import Data.Text.Prettyprint.Doc (Doc, layoutPretty , annotate, reAnnotateS-    , Pretty(..), pretty, emptyDoc+    , unAnnotateS, Pretty(..), pretty, emptyDoc     , LayoutOptions(LayoutOptions)     , PageWidth(AvailablePerLine)     , hsep, vcat, group, flatAlt@@ -71,8 +72,10 @@ printer and embossed with beautiful ANSI colours when printed to the terminal. -Use 'render' to build text object for later use or "Core.Program.Execute"'s-'Core.Program.Execute.writeR' if you're writing directly to console now.+Use 'render' to build text object for later use or+<https://hackage.haskell.org/package/core-program/docs/Core-Program-Logging.html Control.Program.Logging>'s+<https://hackage.haskell.org/package/core-program/docs/Core-Program-Logging.html#v:writeR writeR>+if you're writing directly to console now. -}  class Render α where@@ -113,7 +116,6 @@     colourize = const mempty     intoDocA t = pretty t - -- (), aka Unit, aka **1**, aka something with only one inhabitant  instance Render Bytes where@@ -198,6 +200,20 @@     options = LayoutOptions (AvailablePerLine (columns - 1) 1.0)   in     intoRope . renderLazy . reAnnotateS (colourize @α)+                . layoutPretty options . intoDocA $ thing++{-|+Having gone to all the trouble to colourize your rendered types...+sometimes you don't want that. This function is like 'render', but removes+all the ANSI escape codes so it comes outformatted but as plain black &+white text.+-}+renderNoAnsi :: Render α => Int -> α -> Rope+renderNoAnsi columns (thing :: α) =+  let+    options = LayoutOptions (AvailablePerLine (columns - 1) 1.0)+  in+    intoRope . renderLazy . unAnnotateS                 . layoutPretty options . intoDocA $ thing  --