packages feed

uniqueness-periods-vector-common 0.3.0.0 → 0.4.0.0

raw patch · 3 files changed

+51/−37 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -12,3 +12,7 @@  * Third version. Changed the Languages.UniquenessPeriods.Vector.Data module so that the uniqueness-periods-vector-general package can be fixed and rewritten to  follow the requirements. These changes break the previous behaviour, so check the code.++## 0.4.0.0 -- 2020-09-28++* Fourth version. Simplified the uniquenessVariants2GNP function so that it does not use backpermute function from Data.Vector and permutations from Data.List simultanously. 
Languages/UniquenessPeriods/Vector/StrictV.hs view
@@ -5,11 +5,11 @@ -- Stability   :  Experimental -- Maintainer  :  olexandr543@yahoo.com ----- Generalization of the DobutokO.Poetry.StrictV module functionality from --- the @dobutokO-poetry-general@ package. --- Can be used to get possible permutations of no more than 7 sublists --- in the list separated with the elements of the \"whitespace symbols\" --- list. +-- Generalization of the DobutokO.Poetry.StrictV module functionality from+-- the @dobutokO-poetry-general@ package.+-- Can be used to get possible permutations of no more than 7 sublists+-- in the list separated with the elements of the \"whitespace symbols\"+-- list.  {-# LANGUAGE CPP, BangPatterns #-} @@ -22,53 +22,63 @@ import Prelude hiding ((<>)) #endif #endif-+#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__>=710+/* code that applies only to GHC 7.10.* and higher versions */+import GHC.Base (mconcat)+#endif+#endif import qualified Data.Vector as V-import qualified Data.List as L (permutations,intersperse)+import qualified Data.List as L (permutations)+#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif --- | Given a [a] consisting of no more than 7 sublists interspersed with the elements of the first argument, --- it returns a 'V.Vector' of possible combinations without repeating of the sublists in different order and for each of them appends also --- the information about generalized \"uniqueness periods\" (see @uniqueness-periods-vector@ package) to it and finds out --- some different metrics -- named \"properties\". --- --- Afterwards, depending on these norms some (usually phonetic for the words) properties of the sublists can be specified that --- allow to use them for special cases of repetitions (usually, for the words -- poetically or to create a varied melody with them). -uniquenessVariants2GN :: -  (Eq a, Ord b) => [a] -  -> V.Vector ([b] -> b) -  -> ([a] -> V.Vector c) +-- | Given a [a] consisting of no more than 7 sublists interspersed with the elements of the first argument,+-- it returns a 'V.Vector' of possible combinations without repeating of the sublists in different order and for each of them appends also+-- the information about generalized \"uniqueness periods\" (see @uniqueness-periods-vector@ package) to it and finds out+-- some different metrics -- named \"properties\".+--+-- Afterwards, depending on these norms some (usually phonetic for the words) properties of the sublists can be specified that+-- allow to use them for special cases of repetitions (usually, for the words -- poetically or to create a varied melody with them).+uniquenessVariants2GN ::+  (Eq a, Ord b) => [a]+  -> V.Vector ([b] -> b)+  -> ([a] -> V.Vector c)   -> (V.Vector c -> [b])-  -> [a] +  -> [a]   -> V.Vector ([b],V.Vector b, [a])-uniquenessVariants2GN whspss vN g1 g2 !xs = uniquenessVariants2GNP [] [] whspss vN g1 g2 xs +uniquenessVariants2GN whspss vN g1 g2 !xs = uniquenessVariants2GNP [] [] whspss vN g1 g2 xs {-# INLINE uniquenessVariants2GN #-}-        --- | Generalized variant of 'uniquenessVariants2GN' with prepending and appending @[a]@ (given as the first and the second argument). -uniquenessVariants2GNP :: -  (Eq a, Ord b) => [a] -  -> [a] -  -> [a] -  -> V.Vector ([b] -> b) -  -> ([a] -> V.Vector c) -  -> (V.Vector c -> [b]) -  -> [a] ++-- | Generalized variant of 'uniquenessVariants2GN' with prepending and appending @[a]@ (given as the first and the second argument).+uniquenessVariants2GNP ::+  (Eq a, Ord b) => [a]+  -> [a]+  -> [a]+  -> V.Vector ([b] -> b)+  -> ([a] -> V.Vector c)+  -> (V.Vector c -> [b])+  -> [a]   -> V.Vector ([b],V.Vector b, [a])-uniquenessVariants2GNP !ts !us whspss vN g1 g2 !xs +uniquenessVariants2GNP !ts !us whspss vN g1 g2 !xs   | null . sublistsG whspss $ xs = V.empty-  | not . null $ whspss = let !v0 = V.fromList . take 8 . sublistsG whspss $ xs in-     V.fromList . map ((\vs -> let !rs = g2 . g1 $ vs in (rs, (V.map (\f -> f rs) vN), vs)) . concat . L.intersperse (take 1 whspss) . preAppend ts [us] . V.toList . -       V.backpermute v0 . V.fromList) . L.permutations $ ([0..(V.length v0 - 1)]::[Int])+  | not . null $ whspss = let !hd = head whspss in let !ns = take 8 . sublistsG whspss $ xs in+     V.fromList . map ((\vs -> let !rs = g2 . g1 $ vs in (rs, (V.map (\f -> f rs) vN), vs)) . mconcat . preAppend ts [us]) . L.permutations . map (hd:) $ ns   | otherwise = error "Languages.UniquenessPeriods.Vector.StrictV.uniquenessVariants2GNP: undefined for the empty third argument. "  -- | Inspired by: https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.OldList.html#words sublistsG :: Eq a => [a] -> [a] -> [[a]]-sublistsG whspss xs = +sublistsG whspss xs =  case dropWhile (`elem` whspss) xs of    [] -> []    s' -> w : sublistsG whspss s''      where (w, s'') = break (`elem` whspss) s' --- | Prepends and appends the given two first arguments to the third one. +-- | Prepends and appends the given two first arguments to the third one. preAppend :: [a] -> [[a]] -> [[a]] -> [[a]] #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=804
uniqueness-periods-vector-common.cabal view
@@ -2,7 +2,7 @@ --   For further documentation, see http://haskell.org/cabal/users-guide/  name:                uniqueness-periods-vector-common-version:             0.3.0.0+version:             0.4.0.0 synopsis:            Generalization of the dobutokO-poetry-general package functionality description:         Generalization of the dobutokO-poetry-general package functionality. Can be used to rearrange 7 sublists in the list to obtain somewhat more suitable list for some purposes. homepage:            https://hackage.haskell.org/package/uniqueness-periods-vector-common