uniform-strings 0.1.3.1 → 0.1.5.1
raw patch · 4 files changed
+56/−14 lines, 4 filesdep ~uniform-algebras
Dependency ranges changed: uniform-algebras
Files
- ChangeLog.md +21/−0
- Uniform/Strings/Utilities.hs +24/−8
- test/Uniform/Strings/Utilities_test.hs +3/−0
- uniform-strings.cabal +8/−6
ChangeLog.md view
@@ -5,3 +5,24 @@ added LanguageCodes, needs uniform-algebras 0.1.2 for 9.2.1 removed snap-core, because limited with attoparsec <0.14+0.1.3+ pushed on hackage++0.1.3 added stack build lts 19.16 for ghc 9.0.2+0.1.3.1 removed dependency on text-icu0.1.3.2+ added showlong for arrays to list one item per line+0.1.3.3+ import frm similar packages:+ - algebra of programming: https://hackage.haskell.org/package/aop-prelude-0.4.1.1/docs/src/AOPPrelude.html + - from thielmann: https://hackage.haskell.org/package/utility-ht+ - from mitchel : https://hackage.haskell.org/package/extra+ could be better just to copy the code.+ changes: swapPair -> swap, pair -> both++ split off the tuples stuff from the pointless+0.1.3.4 +0.1.3.5 + instance shownice + added shownice with 4 digits precision+ showAsLines - shows list, inside is shown regularly, does not propagate+0.1.5.1 ghc 9.2.5 changed versino to be in sync with other packages
Uniform/Strings/Utilities.hs view
@@ -48,6 +48,7 @@ -- to generalize , dropWhile, takeWhile, span, break , formatInt+ , showAsLines ) where @@ -59,7 +60,7 @@ import Text.Printf (PrintfArg, PrintfType, printf) import Data.List as L- ( sortBy, intercalate, isInfixOf, isPrefixOf, nub, stripPrefix )+ ( sortBy, intercalate, isInfixOf, isPrefixOf, nub, stripPrefix, intersperse ) import GHC.Exts (IsString (..)) import qualified Data.List.Split as S (splitOn)@@ -86,6 +87,7 @@ import Text.Show.Pretty ( ppShow ) import "monads-tf" Control.Monad.State (MonadIO, liftIO) import Control.Monad (when)+import Data.ByteString (intersperse) readNoteTs :: (Show a, Read a) => [Text] -> Text -> a -- TODO@@ -410,6 +412,10 @@ unlinesT :: [Text] -> Text unlinesT = unlines' +showAsLines :: Show a => [a] -> Text+-- ^ show on a line, does not propagate, inside is shown normally+showAsLines = unlines' . map showT + sortCaseInsensitive :: (Ord a, CharChains a) => [a] -> [a] sortCaseInsensitive = sortBy cmpCaseInsensitive @@ -423,10 +429,10 @@ string2maybe :: (Eq a, IsString a) => a -> Maybe a string2maybe x = if x == "" then Nothing else Just x -class NiceStrings a where+class (Show a) => NiceStrings a where shownice, showNice :: a -> Text- showNice = shownice- shownice = showNice + -- showNice = shownice+ shownice = showT -- as default showlong :: a -> Text showlong = shownice -- a default class Show a => PrettyStrings a where @@ -441,18 +447,28 @@ instance NiceStrings Int where shownice = show' showlong = show'++-- instance NiceStrings Float where shownice = s2t . showDP 4++-- for printf https://hackage.haskell.org/package/base-4.17.0.0/docs/Text-Printf.html+instance NiceStrings Float where shownice f = s2t $ printf "%.3f" f+ instance NiceStrings Double where- shownice = show'+ shownice s = s2t . printf "%.3f" $ s showlong = show' instance (NiceStrings a, NiceStrings b) => NiceStrings (a,b) where shownice (a,b) = unwords' [shownice a, shownice b] showlong (a,b) = unwords' [showlong a, showlong b]-instance (NiceStrings a) => NiceStrings [a] where- shownice as = concat' . catMaybes $ [intercalate' "," . map shownice $ as, Just "\n"]- shownice as = concat' . catMaybes $ [intercalate' "," . map showlong $ as, Just "\n"]+instance (Show a, NiceStrings a) => NiceStrings [a] where+ shownice as = concat' . L.intersperse ",\t\t" $ (map shownice as) + showlong as = concat' . L.intersperse ",\n" $ (map shownice as) + -- catMaybes $ [intercalate' "\n" . map showlong $ as, Just "\n"] instance (NiceStrings a) => NiceStrings (Maybe a) where shownice (Just a) = shownice a shownice Nothing = "Nothing"++instance (Show a, Show b, Show c) => NiceStrings (a,b,c) where + showNice a = showT a
test/Uniform/Strings/Utilities_test.hs view
@@ -210,3 +210,6 @@ -- putIOwords ["intercalate' for string", show c1, "-"] -- putIOwords ["intercalate' for text", show c2, "-"] -- return True++test_float1 = assertEqual "3.142" (shownice (pi::Float))+test_double1 = assertEqual "3.142" (shownice (pi::Double))
uniform-strings.cabal view
@@ -1,11 +1,11 @@ cabal-version: 2.2 --- This file has been generated from package.yaml by hpack version 0.35.0.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack name: uniform-strings-version: 0.1.3.1+version: 0.1.5.1 synopsis: Manipulate and convert strings of characters uniformly and consistently description: Reduce complexity of Haskell by providing a .@@ -25,11 +25,9 @@ where the semantic is the same (tested with quickcheck). Tentatively some infix string manipulations are offered as well. .- - 0.1.3 added stack build lts 19.16 for ghc 9.0.2- - 0.1.3.1 removed dependency on text-icu- . Please see the README on GitHub at <https://github.com/andrewufrank/uniform-strings/readme> category: Data Text Uniform+homepage: https://github.com/github.com:andrewufrank/uniform-strings.git#readme bug-reports: https://github.com/andrewufrank/uniform-strings/issues author: Andrew Frank maintainer: Andrew U. Frank <uniform@gerastree.at>@@ -40,6 +38,10 @@ README.md ChangeLog.md +source-repository head+ type: git+ location: https://github.com/github.com:andrewufrank/uniform-strings.git+ library exposed-modules: Uniform.Strings@@ -61,7 +63,7 @@ , snap-core , split , text- , uniform-algebras >=0.1.3+ , uniform-algebras >=0.1.4 default-language: Haskell2010 autogen-modules: Paths_uniform_strings