packages feed

phladiprelio-general-datatype 0.6.0.0 → 0.7.0.0

raw patch · 4 files changed

+44/−34 lines, 4 filesdep +containersPVP ok

version bump matches the API change (PVP)

Dependencies added: containers

API changes (from Hackage documentation)

+ Phladiprelio.General.Datatype3: readU2 :: String -> Double
- Phladiprelio.General.Datatype3: basicSplit :: String -> [Read0]
+ Phladiprelio.General.Datatype3: basicSplit :: String -> Seq Read0
- Phladiprelio.General.Datatype3: line2Strings :: (String -> Bool) -> (String -> [String]) -> [Read0] -> [String]
+ Phladiprelio.General.Datatype3: line2Strings :: (String -> Bool) -> (String -> [String]) -> Seq Read0 -> [String]
- Phladiprelio.General.Datatype3: readEq4 :: (String -> [Double]) -> (String -> [String]) -> [Read0] -> [(String, Double)]
+ Phladiprelio.General.Datatype3: readEq4 :: (String -> [Double]) -> (String -> [String]) -> Seq Read0 -> [(String, Double)]
- Phladiprelio.General.Datatype3: readEq4G :: (String -> Bool) -> (String -> [Double]) -> (String -> [String]) -> [Read0] -> [(String, Double)]
+ Phladiprelio.General.Datatype3: readEq4G :: (String -> Bool) -> (String -> [Double]) -> (String -> [String]) -> Seq Read0 -> [(String, Double)]
- Phladiprelio.General.Datatype3: readSimple3 :: (String -> Bool) -> Double -> (String -> [Double]) -> [Read0] -> [Double]
+ Phladiprelio.General.Datatype3: readSimple3 :: (String -> Bool) -> Double -> (String -> [Double]) -> Seq Read0 -> [Double]

Files

CHANGELOG.md view
@@ -61,3 +61,7 @@  * Sixth version. Removed the module Phladiprelio.General.Datatype except readU2 function that moved to the Phladiprelio.General.Datatype3 module because the removed functionality in extended version is provided by the Phladiprelio.General.Datatype3 module. To find the removed functionality, please, refer to the versions up to 0.5.2.0. Fixed issue with the readSimple3 function for '=' after just one syllable.  +## 0.7.0.0 -- 2024-01-21++* Seventh version. Switched to more time efficient imlementation using Data.Sequence functionality from the containers package. Added it as a new (widely used in many cases) dependency. Some code and documentation improvements. Added readU2 to the export list of the Phladiprelio.General.Datatype3 module.+
Phladiprelio/General/Datatype3.hs view
@@ -6,6 +6,7 @@    , isA    , isB    , isC +   , readU2    , readSimple3    , basicSplit    , line2Strings@@ -23,6 +24,8 @@ import GHC.Num ((*),(+)) import Data.Maybe (fromMaybe) import Data.Tuple (snd)+import qualified Data.Foldable as F (foldr) +import qualified Data.Sequence as S  -- | Is a way to read duration of the additional added time period into the line. readU2 :: String -> Double@@ -30,17 +33,19 @@ readU2 _ = 1.0 {-# INLINE readU2 #-} +-- | Splits a 'String' into list of 'String' so that they can be read by other functions here into respective datatypes. splitL0 :: String -> [String] splitL0 = groupBy (\x y -> (isDigit x && isDigit y) || (x /= '_' && x /= '=' && not (isDigit x) && y /= '_' && y /= '=' && not (isDigit y)) || ((x == '=' || x == '_') && isDigit y)) {-# INLINE splitL0 #-}  data Read0 = A {-# UNPACK #-} !Double | B {-# UNPACK #-} !Double | C String deriving (Eq, Show) +-- | Converts a specially formatted 'String' into a 'Read0' value. reRead3 :: String -> Read0 reRead3 xs = -  case splitAt 1 xs of-    ("=",ts) -> A (readU2 ts)-    ("_",ts) -> B (readU2 ts)+  case uncons xs of+    Just ('=',ts) -> A (readU2 ts)+    Just ('_',ts) -> B (readU2 ts)     _ -> C xs  isA :: Read0 -> Bool@@ -55,13 +60,14 @@ isC (C _) = True isC _ = False -filterReads :: [Read0] -> [Read0]-filterReads xs@(B y:A t:us) = B y : filterReads (dropWhile isA us)-filterReads xs@(A y:A t:us) = A y : filterReads (dropWhile isA us)-filterReads xs@(t:ts) = t:filterReads ts-filterReads _ = []+filterReads :: [Read0] -> S.Seq Read0+filterReads xs@(B y:A t:us) = B y S.<| filterReads (dropWhile isA us)+filterReads xs@(A y:A t:us) = A y S.<| filterReads (dropWhile isA us)+filterReads xs@(t:ts) = t S.<| filterReads ts+filterReads _ = S.empty -basicSplit :: String -> [Read0]+-- | A preparatory function for the further ones here.+basicSplit :: String -> S.Seq Read0 basicSplit = filterReads . map reRead3 . splitL0 {-# INLINE basicSplit #-} @@ -69,9 +75,9 @@   :: (String -> Bool) -- ^ A special function to check whether the 'String' contains needed information. Must return 'True' for the 'String' that contains the needed for usual processment information, otherwise — 'False'.   -> Double   -> (String -> [Double])-  -> [Read0]+  -> S.Seq Read0 -- ^ Is should be obtained using 'basicSplit' function here.   -> [Double]-readSimple3 p temp fConvA rs@(C xs:A x:ts) -- This branch is fixed in the version 0.6.0.0 because earlier it has an issue.+readSimple3 p temp fConvA rs@(C xs S.:<| A x S.:<| ts) -- This branch is fixed in the version 0.6.0.0 because earlier it has an issue.  | null qs = readSimple3 p temp fConvA ts  | null q1 = xl1 : readSimple3 p xl1 fConvA ts  | otherwise = q1 `mappend` (xl1 : readSimple3 p xl1 fConvA ts)@@ -81,24 +87,23 @@         (q1,q2s) = splitAtEnd 1 qs         ql1 = head q2s         xl1=x*ql1-readSimple3 p temp fConvA rs@(C xs:ys@(B x:ts)) = qs `mappend` qqs `mappend` readSimple3 p ql fConvA ws  -  where (ks, ws) = span isB ys+readSimple3 p temp fConvA rs@(C xs S.:<| ys@(B x S.:<| ts)) = qs `mappend` qqs `mappend` readSimple3 p ql fConvA ws  +  where (ks, ws) = S.spanl isB ys         qs            | p xs = fConvA xs           | otherwise = []         ql           | null qs = 0.0           | otherwise = last qs-        qqs = map (\(B k) -> k * ql) ks-readSimple3 p temp fConvA rs@(B x:ts) = qqs `mappend` readSimple3 p temp fConvA ws -  where (ks, ws) = span isB rs-        qqs = map (\(B k) -> k * temp) ks-readSimple3 p temp fConvA [C xs] = qs+        qqs = F.foldr (\(B k) js -> k * ql:js) [] ks+readSimple3 p temp fConvA rs@(B x S.:<| ts) = qqs `mappend` readSimple3 p temp fConvA ws +  where (ks, ws) = S.spanl isB rs+        qqs = F.foldr (\(B k) js -> k * temp:js) [] ks+readSimple3 p temp fConvA (C xs S.:<| _) = qs   where qs            | p xs = fConvA xs           | otherwise = [] readSimple3 _ _ _ _ = []-{-# INLiNABLE readSimple3 #-}  read3   :: (String -> Bool) -- ^ A special function to check whether the 'String' contains needed information. Must return 'True' for the 'String' that contains the needed for usual processment information, otherwise — 'False'.@@ -116,7 +121,7 @@         | k < n = (x : zs,[],k + 1,n)         | otherwise = (zs,x : ts,k + 1,n) --- | Is a specialized version of 'Data.SubG.dropFromEndG' function variant from the @subG@ package. Is taken from there to+-- | Is a specialized version of 'Data.InsertLeft.dropFromEndG' function variant from the @subG@ package. Is taken from there to -- reduce the dependencies. Is not intended to be exported at all. dropFromEnd :: Int -> [a] -> [a] dropFromEnd n = (\(xs,_,_) -> xs) . foldr f v@@ -128,36 +133,35 @@ line2Strings   :: (String -> Bool) -- ^ A special function to check whether the 'String' contains needed information. Must return 'True' for the 'String' that contains the needed for usual processment information, otherwise — 'False'.  -> (String -> [String])- -> [Read0]+ -> S.Seq Read0 -- ^ Is should be obtained using 'basicSplit' function here.  -> [String]-line2Strings p gConvC xs@(C ts:tt@(A x):ys) = ks `mappend` ((ql `mappend` (if null ql then [] else '=':showRead0AsInsert tt)) : line2Strings p gConvC ys) +line2Strings p gConvC xs@(C ts S.:<| tt@(A x) S.:<| ys) + | null qs = ks `mappend` line2Strings p gConvC ys+ | otherwise = ks `mappend` ((ql `mappend` ('=':showRead0AsInsert tt)) : line2Strings p gConvC ys)    where (ks, qs)            | p ts = splitAtEnd 1 . gConvC $ ts            | otherwise = ([],[])-        ql -          | null qs = []-          | otherwise = head qs-line2Strings p gConvC xs@(C ys:ts) = gConvC ys `mappend` line2Strings p gConvC ts-line2Strings p gConvC xs@(y@(B x):ts) = showRead0AsInsert y : line2Strings p gConvC ts+        ql = head qs+line2Strings p gConvC xs@(C ys S.:<| ts) = gConvC ys `mappend` line2Strings p gConvC ts+line2Strings p gConvC xs@(y@(B x) S.:<| ts) = showRead0AsInsert y : line2Strings p gConvC ts line2Strings _ _ _ = []-{-# INLINABLE line2Strings #-}  -- | Is intended to be used in the "music" mode for PhLADiPreLiO. readEq4G   :: (String -> Bool) -- ^ A special function to check whether the 'String' contains needed information. Must return 'True' for the 'String' that contains the needed for usual processment information, otherwise — 'False'.  -> (String -> [Double])  -> (String -> [String])- -> [Read0]+ -> S.Seq Read0 -- ^ Is should be obtained using 'basicSplit' function here.  -> [(String, Double)] readEq4G p fConvA gConvC xs = zip ks rs    where ks = line2Strings p gConvC xs          rs = filter (/= 0.0) . readSimple3 p 1.0 fConvA $ xs-{-# INLINABLE readEq4G #-}+{-# INLINE readEq4G #-}  readEq4  :: (String -> [Double])  -> (String -> [String])- -> [Read0]+ -> S.Seq Read0 -- ^ Is should be obtained using 'basicSplit' function here.  -> [(String, Double)] readEq4 = readEq4G (not . null . filter (not . isSpace)) {-# INLINE readEq4 #-}
README.md view
@@ -2,7 +2,7 @@ lines are easy to pronounce and read while others are not. They are in two languages by the  following links: -[Чому деякі рядки легко вимовляти,а інші — ні,або Просодична неспрогнозованість як характеристика тексту](https://www.academia.edu/105067723/%D0%A7%D0%BE%D0%BC%D1%83_%D0%B4%D0%B5%D1%8F%D0%BA%D1%96_%D1%80%D1%8F%D0%B4%D0%BA%D0%B8_%D0%BB%D0%B5%D0%B3%D0%BA%D0%BE_%D0%B2%D0%B8%D0%BC%D0%BE%D0%B2%D0%BB%D1%8F%D1%82%D0%B8_%D0%B0_%D1%96%D0%BD%D1%88%D1%96_%D0%BD%D1%96_%D0%B0%D0%B1%D0%BE_%D0%BF%D1%80%D0%BE%D1%81%D0%BE%D0%B4%D0%B8%D1%87%D0%BD%D0%B0_%D0%BD%D0%B5%D1%81%D0%BF%D1%80%D0%BE%D0%B3%D0%BD%D0%BE%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D1%96%D1%81%D1%82%D1%8C_%D1%8F%D0%BA_%D1%85%D0%B0%D1%80%D0%B0%D0%BA%D1%82%D0%B5%D1%80%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0_%D1%82%D0%B5%D0%BA%D1%81%D1%82%D1%83)+[Чому деякі рядки легко вимовляти,а інші — ні, або Просодична неспрогнозованість як характеристика тексту](https://www.academia.edu/105067723/%D0%A7%D0%BE%D0%BC%D1%83_%D0%B4%D0%B5%D1%8F%D0%BA%D1%96_%D1%80%D1%8F%D0%B4%D0%BA%D0%B8_%D0%BB%D0%B5%D0%B3%D0%BA%D0%BE_%D0%B2%D0%B8%D0%BC%D0%BE%D0%B2%D0%BB%D1%8F%D1%82%D0%B8_%D0%B0_%D1%96%D0%BD%D1%88%D1%96_%D0%BD%D1%96_%D0%B0%D0%B1%D0%BE_%D0%BF%D1%80%D0%BE%D1%81%D0%BE%D0%B4%D0%B8%D1%87%D0%BD%D0%B0_%D0%BD%D0%B5%D1%81%D0%BF%D1%80%D0%BE%D0%B3%D0%BD%D0%BE%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D1%96%D1%81%D1%82%D1%8C_%D1%8F%D0%BA_%D1%85%D0%B0%D1%80%D0%B0%D0%BA%D1%82%D0%B5%D1%80%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0_%D1%82%D0%B5%D0%BA%D1%81%D1%82%D1%83)  [Why some lines are easy to pronounce and others are not, or prosodic unpredictability as a characteristic of text](https://www.academia.edu/105067761/Why_some_lines_are_easy_to_pronounce_and_others_are_not_or_prosodic_unpredictability_as_a_characteristic_of_text) @@ -26,6 +26,8 @@ important celebrations — Intercession of the Holy Theotokos (Pokrova), Cossacks' Day, Day of Defenders of Ukraine (especially relevant during the Russian war against Ukraine).  On the 11/11/2023 there is St. Martin of Tours Day for Roman Catholics.++On the 06/01/2024 there was Sophie's Kok, a sister of Emma Kok, 19th Birthday (she is 18). Therefore, the version 0.7.0.0 is additionally devoted also to her.  All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees.  
phladiprelio-general-datatype.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.24 name:               phladiprelio-general-datatype-version:            0.6.0.0+version:            0.7.0.0 synopsis:           Extended functionality of PhLADiPreLiO description:        Can be used not only for language, but also for simpler music and lyrics composing. homepage:           https://hackage.haskell.org/package/phladiprelio-general-datatype@@ -20,6 +20,6 @@     -- other-modules:     other-extensions: NoImplicitPrelude, BangPatterns     ghc-options:      -funbox-strict-fields-    build-depends:    base >=4.13 && <5+    build-depends:    base >=4.13 && <5, containers >=0.5.11.0 && <1     hs-source-dirs:   .     default-language: Haskell2010