diff --git a/core-program/core-program.cabal b/core-program/core-program.cabal index 9b24958d..ba69536c 100644 --- a/core-program/core-program.cabal +++ b/core-program/core-program.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: core-program -version: 0.4.5.2 +version: 0.4.5.3 synopsis: Opinionated Haskell Interoperability description: A library to help build command-line programs, both tools and longer-running daemons. @@ -58,8 +58,8 @@ library , base >=4.11 && <5 , bytestring , chronologique - , core-data >=0.2.1.11 - , core-text >=0.3.4.0 + , core-data >=0.3.2.2 + , core-text >=0.3.7.0 , directory , exceptions , filepath diff --git a/core-program/lib/Core/Program/Metadata.hs b/core-program/lib/Core/Program/Metadata.hs index c0a926e2..4153afcc 100644 --- a/core-program/lib/Core/Program/Metadata.hs +++ b/core-program/lib/Core/Program/Metadata.hs @@ -25,7 +25,6 @@ import Core.Data import Core.System.Base (IOMode (..), withFile) import Core.System.Pretty import Core.Text -import Data.List (intersperse) import qualified Data.List as List (find, isSuffixOf) import Data.Maybe (fromMaybe) import Data.String @@ -148,23 +147,21 @@ readCabalFile = runIO $ do -- pass to calling program return pairs +-- TODO this could be improved; we really only need the data from the first +-- block of lines, with colons in them! We're probably reached the point where +-- a proper parser would be good, but whatever. parseCabalFile :: Bytes -> Map Rope Rope parseCabalFile contents = - let breakup = intoMap . fmap (breakRope' (== ':')) . breakLines . fromBytes + let breakup = intoMap . fmap (\(a, b) -> (a, trimValue b)) . fmap (breakRope (== ':')) . breakLines . fromBytes in breakup contents --- this should probably be a function in Core.Text.Rope -breakRope' :: (Char -> Bool) -> Rope -> (Rope, Rope) -breakRope' predicate text = - let pieces = take 2 (breakPieces predicate text) - in case pieces of - [] -> ("", "") - [one] -> (one, "") - (one : two : _) -> (one, trimRope two) - --- knock off the whitespace in "name: hello" -trimRope :: Rope -> Rope -trimRope = mconcat . intersperse " " . breakWords +-- knock off the colon and whitespace in ": hello" +trimValue :: Rope -> Rope +trimValue value = case unconsRope value of + Nothing -> emptyRope + Just (_, remainder) -> case findIndexRope (/= ' ') remainder of + Nothing -> emptyRope + Just i -> snd (splitRope i remainder) {- | Access the source location of the call site. diff --git a/core-program/package.yaml b/core-program/package.yaml index 6af0e05a..df43c843 100644 --- a/core-program/package.yaml +++ b/core-program/package.yaml @@ -1,5 +1,5 @@ name: core-program -version: 0.4.5.2 +version: 0.4.5.3 synopsis: Opinionated Haskell Interoperability description: | A library to help build command-line programs, both tools and @@ -36,8 +36,8 @@ dependencies: library: dependencies: - async - - core-text >= 0.3.4.0 - - core-data >= 0.2.1.11 + - core-text >= 0.3.7.0 + - core-data >= 0.3.2.2 - chronologique - directory - exceptions diff --git a/core-telemetry/core-telemetry.cabal b/core-telemetry/core-telemetry.cabal index ed7b0657..58ea018e 100644 --- a/core-telemetry/core-telemetry.cabal +++ b/core-telemetry/core-telemetry.cabal @@ -5,7 +5,7 @@ cabal-version: 1.18 -- see: https://github.com/sol/hpack name: core-telemetry -version: 0.1.9.3 +version: 0.1.9.4 synopsis: Advanced telemetry description: This is part of a library to help build command-line programs, both tools and longer-running daemons. @@ -53,9 +53,9 @@ library , base >=4.11 && <5 , bytestring , chronologique - , core-data >=0.2.1.11 - , core-program >=0.4.4 - , core-text >=0.3.5 + , core-data >=0.3.2.2 + , core-program >=0.4.5.3 + , core-text >=0.3.6.0 , exceptions , http-streams , io-streams diff --git a/core-telemetry/package.yaml b/core-telemetry/package.yaml index 2d1906bd..b14aa299 100644 --- a/core-telemetry/package.yaml +++ b/core-telemetry/package.yaml @@ -1,5 +1,5 @@ name: core-telemetry -version: 0.1.9.3 +version: 0.1.9.4 synopsis: Advanced telemetry description: | This is part of a library to help build command-line programs, both tools and @@ -33,9 +33,9 @@ dependencies: library: dependencies: - async - - core-text >= 0.3.5 - - core-data >= 0.2.1.11 - - core-program >= 0.4.4 + - core-text >= 0.3.6.0 + - core-data >= 0.3.2.2 + - core-program >= 0.4.5.3 - chronologique - exceptions - http-streams diff --git a/core-text/core-text.cabal b/core-text/core-text.cabal index 19d4efb7..af0de60d 100644 --- a/core-text/core-text.cabal +++ b/core-text/core-text.cabal @@ -5,7 +5,7 @@ cabal-version: 1.18 -- see: https://github.com/sol/hpack name: core-text -version: 0.3.7.0 +version: 0.3.7.1 synopsis: A rope type based on a finger tree over UTF-8 fragments description: 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 diff --git a/core-text/lib/Core/Text/Rope.hs b/core-text/lib/Core/Text/Rope.hs index 267e231a..754e154b 100644 --- a/core-text/lib/Core/Text/Rope.hs +++ b/core-text/lib/Core/Text/Rope.hs @@ -124,7 +124,7 @@ import qualified Data.FingerTree as F ( (><), (|>), ) -import Data.Foldable (foldl', foldr', toList) +import Data.Foldable (foldl', toList) import Data.Hashable (Hashable, hashWithSalt) import Data.String (IsString (..)) import qualified Data.Text as T (Text) @@ -148,14 +148,14 @@ import qualified Data.Text.Short as S ( fromByteString, fromText, length, - null, pack, replicate, singleton, splitAt, toBuilder, toText, - unpack, uncons + uncons, + unpack, ) import qualified Data.Text.Short.Unsafe as S (fromByteStringUnsafe) import GHC.Generics (Generic) @@ -324,14 +324,13 @@ replicateChar count = Rope . F.singleton . S.replicate count . S.singleton Get the length of this text, in characters. -} widthRope :: Rope -> Int -widthRope = foldr' f 0 . unRope - where - f piece count = S.length piece + count +widthRope text = + let x = unRope text + (Width w) = F.measure x + in w nullRope :: Rope -> Bool -nullRope (Rope x) = case F.viewl x of - F.EmptyL -> True - (F.:<) piece _ -> S.null piece +nullRope text = widthRope text == 0 {- | Read the first character from a 'Rope', assuming it's length 1 or greater, @@ -350,7 +349,6 @@ unconsRope text = Nothing -> Nothing Just (c, piece') -> Just (c, Rope ((F.<|) piece' x')) - {- | Break the text into two pieces at the specified offset. diff --git a/core-text/package.yaml b/core-text/package.yaml index 12fa20f2..a863feb5 100644 --- a/core-text/package.yaml +++ b/core-text/package.yaml @@ -1,5 +1,5 @@ name: core-text -version: 0.3.7.0 +version: 0.3.7.1 synopsis: A rope type based on a finger tree over UTF-8 fragments description: | A rope data type for text, built as a finger tree over UTF-8 text