packages feed

uniqueness-periods-vector-general 0.2.0.0 → 0.2.0.1

raw patch · 3 files changed

+104/−86 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Languages.UniquenessPeriods.Vector.General.Debug: toFile :: String -> [String] -> IO ()
+ Languages.UniquenessPeriods.Vector.General.Debug: toFile :: FilePath -> [String] -> IO ()

Files

ChangeLog.md view
@@ -8,3 +8,7 @@  * Second version. Added the possibility to define what output to be printed (but not its order) using the new imported dependency module Data.Print.Info  from print-info module. Some documentation improvements.++## 0.2.0.1 -- 2020-09-07++* Second version revised A. Added more documentation.
Languages/UniquenessPeriods/Vector/General/Debug.hs view
@@ -18,12 +18,16 @@ import Languages.UniquenessPeriods.Vector.StrictV import Languages.UniquenessPeriods.Vector.Data --- | +-- | The function evaluates the 'V.Vector' of 'UniquenessG1' @a@ @b@ elements (related with the third argument) to retrieve the possibly maximum element +-- in it with respect to the order and significance (principality)  of the \"properties\" (represented as the functions @f :: [b] -> b@) being evaluated. +-- The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument (so it is the first one) of the +-- function minus 1, then less significant is the next to the left \"property\" and so on. +-- The predefined library \"properties\" or related to them functions can be found in the package @uniqueness-periods-vector-properties@.  uniqMaxPoeticalGNV :: -  (Eq a, Ord b) => Int -  -> V.Vector ([b] -> b) -  ->  UniqG a b -  -> UniquenessG1 a b+  (Eq a, Ord b) => Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  ->  UniqG a b -- ^ The data to be analyzed.+  -> UniquenessG1 a b -- ^ The maximum element in respect with the given parameters. uniqMaxPoeticalGNV k vN y  | compare k (V.length vN) == GT = error "Languages.UniquenessPeriods.Vector.General.Debug.uniqMaxPoeticalGNV: undefined for that amount of norms. "  | compare k 0 == GT =@@ -35,7 +39,10 @@ {-# INLINE uniqMaxPoeticalGNV #-}  -- | Inspired by appendS16LEFile function from Melodics.Ukrainian module from @mmsyn6ukr@ package.-toFile :: String -> [String] -> IO ()+toFile :: +  FilePath -- ^ The 'FilePath' to the file to be written in the 'AppendMode' (actually appended with) the information output.+  -> [String] -- ^ Each 'String' is appended on the new line to the file.+  -> IO () toFile file xss = withFile file AppendMode (\hdl -> do     hClose hdl     closedHdl <- hIsClosed hdl@@ -44,10 +51,10 @@       else error "The handle is not closed!"     hClose hdl) --- | Is used to print output specified to the stdout or to the FilePath specified as the inner argument in the 'Info2' parameter.+-- | Is used to print output specified to the 'stdout' or to the 'FilePath' specified as the inner argument in the 'Info2' parameter. printHelp -  :: (Show a, Show b) => Info2 -  -> UniquenessG1 a b+  :: (Show a, Show b) => Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> UniquenessG1 a b -- ^ The element, for which the information is printed.   -> IO () printHelp info uni    | isI1 info = @@ -71,12 +78,12 @@         Gf xs -> toFile xs [show . firstFrom3 $ uni, show . secondFrom3 $ uni]         ~(Hf xs) -> toFile xs [show . lastFrom3 $ uni, show . firstFrom3 $ uni, show. secondFrom3 $ uni]  -- the most verbose output --- | +-- | Auxiliary function that is used inside the 'uniqInMaxPoeticalN'. Finds the maximum element, prints needed information and returns the result.  inner1 :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO ([b],UniqG a b) inner1 k info vN x = do    let uniq = uniqMaxPoeticalGNV k vN x@@ -85,23 +92,27 @@   return (fsT,x) {-# INLINE inner1 #-} --- | +-- | Variant of the 'uniqMaxPoeticalGNV' function where all the given \"properties\" are used. +-- The predefined library \"properties\" or related to them functions can be found in the package @uniqueness-periods-vector-properties@. uniqMaxPoeticalGNVL :: -  (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) -  ->  UniqG a b -  -> UniquenessG1 a b+  (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  ->  UniqG a b -- ^ The data to be analyzed.+  -> UniquenessG1 a b -- ^ The maximum element according to the given \"properties\". uniqMaxPoeticalGNVL vN = uniqMaxPoeticalGNV (V.length vN) vN {-# INLINE uniqMaxPoeticalGNVL #-} --- | +-- | The function evaluates +-- the generated 'V.Vector' of 'UniquenessG1' @a@ @b@ elements to retrieve the possibly maximum element in it with respect to the order and significance (principality) +-- of the \"properties\" being evaluated. The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument of the function +-- minus 1, then less significant is the next to the left \"property\" and so on. uniqMaxPoetical2GN :: -  (Eq a, Ord b, Show a, Show b) => [a] -  -> Preapp a-  -> Int -  -> V.Vector ([b] -> b) -  ->  ([a] -> V.Vector c)-  -> (V.Vector c -> [b]) -  -> [a] +  (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.+  -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. +  -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  ->  ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module.+  -> (V.Vector c -> [b]) -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result.+  -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text.    -> UniquenessG1 a b uniqMaxPoetical2GN whspss rr k vN g1 g2 xs  | compare k (V.length vN) == GT = error "Languages.UniquenessPeriods.Vector.General.Debug.uniqMaxPoetical2GN: undefined for that amount of norms. "@@ -112,25 +123,26 @@          uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (U vK)  | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . uniquenessVariantsGN whspss rr vN g1 g2 $ xs --- | +-- | A variant for 'uniquenessVariants2GN' and 'uniquenessVariants2GNP' with the second argument defining, which one is used. uniquenessVariantsGN :: -  (Eq a, Ord b, Show a, Show b) => [a] -  -> Preapp a -  -> V.Vector ([b] -> b) -  ->  ([a] -> V.Vector c)-  -> (V.Vector c -> [b]) -  -> [a] +  (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.+  -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. +  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  ->  ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module.+  -> (V.Vector c -> [b])  -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result.+  -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text.     -> V.Vector (UniquenessG1 a b) uniquenessVariantsGN whspss (PA ts us) vN g1 g2 = uniquenessVariants2GNP ts us whspss vN g1 g2 uniquenessVariantsGN whspss K vN g1 g2 = uniquenessVariants2GN whspss vN g1 g2 {-# INLINE uniquenessVariantsGN #-} --- | +-- | Prints the maximum element with respect of the @k@ \"properties\" (the most significant of which is the rightest one, then to the left less significant etc.), +-- which is given as the first argument. The last \"property\" is the first element in the 'V.Vector' of \"properties\" (@[b] -> b@).  uniqInMaxPoeticalN :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO (UniqG a b) uniqInMaxPoeticalN k info vN x = do   inner1 k info vN x >>= \(fsT,x) -> @@ -139,74 +151,76 @@       V.unstablePartition (\(xs,_,_) -> xs == fsT) . snd . get2 $ x)) {-# INLINE uniqInMaxPoeticalN #-}   --- | +-- | A variant of the 'uniqInMaxPoeticalN' where all the given \"properties\" are used. uniqInMaxPoeticalNL :: -  (Eq a, Ord b, Show a, Show b) => Info2 -  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO (UniqG a b) uniqInMaxPoeticalNL info vN = uniqInMaxPoeticalN (V.length vN) info vN {-# INLINE uniqInMaxPoeticalNL #-} --- | +-- |  Is a pair function for monadic recursive calls with 'uniqInMaxPoeticalN'. Prints the @n@ (the first 'Int' argument) consequential maximum elements.  uniqNPoeticalN :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b -> IO ()+  (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.+  -> IO () uniqNPoeticalN n k info vN y    | n <= 0 = return ()  | compare (V.length . snd . get2 $ y) n == LT = V.mapM_ (printHelp info) . snd . get2 $ y  | otherwise = (uniqInMaxPoeticalN k info vN y >>= uniqNPoeticalN (n - 1) k info vN) {-# INLINE uniqNPoeticalN #-} --- | +-- | A variant of the 'uniqNPoeticalN' where all the given \"properties\" are used. uniqNPoeticalNL :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO () uniqNPoeticalNL n info vN = uniqNPoeticalN n (V.length vN) info vN {-# INLINE uniqNPoeticalNL #-} --- | +-- |  Is a pair function for monadic recursive calls with 'uniqInMaxPoeticalN'. Prints the @n@ (the first 'Int' argument) consequential maximum elements. +-- Is similar to 'uniqNPoeticalN' in actions but has another return data type. uniqNPoeticalVN :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO (UniqG a b) uniqNPoeticalVN n k info vN y  | n <= 0 || compare (V.length . snd . get2 $ y) n == LT = return y  | otherwise = (uniqInMaxPoeticalN k info vN y >>= uniqNPoeticalVN (n - 1) k info vN) {-# INLINE uniqNPoeticalVN #-} --- | +-- | A variant of the 'uniqNPoeticalVN' where all the given \"properties\" are used. uniqNPoeticalVNL :: -  (Eq a, Ord b, Show a, Show b) => Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> UniqG a b +  (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> UniqG a b -- ^ The data to be analyzed.   -> IO (UniqG a b) uniqNPoeticalVNL n info vN = uniqNPoeticalVN n (V.length vN) info vN {-# INLINE uniqNPoeticalVNL #-}  -------------------------------------------------------------------------------------------- --- | +-- | The full analyzing and processment function. A pair with 'uniqNPoetical2VGN', returns another data type as its result. uniqNPoetical2GN :: -  (Eq a, Ord b, Show a, Show b) => [a]-  -> Preapp a -  -> Int -  -> Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> ([a] -> V.Vector c)-  -> (V.Vector c -> [b]) -  -> [a] +  (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.+  -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. +  -> Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module.+  -> (V.Vector c -> [b])  -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result.+  -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text.     -> IO () uniqNPoetical2GN whspss rr n k info vN g1 g2 xs  | n <= 0 = return ()@@ -216,18 +230,18 @@      then V.mapM_ (printHelp info) v      else (uniqInMaxPoeticalN k info vN (U v) >>= uniqNPoeticalN (n - 1) k info vN) --- | +-- | The full analyzing and processment function. A pair with 'uniqNPoetical2GN', returns another data type as its result. uniqNPoetical2VGN :: -  (Eq a, Ord b, Show a, Show b) => [a]-  -> Preapp a -  -> Int -  -> Int -  -> Info2-  -> V.Vector ([b] -> b) -  -> ([a] -> V.Vector c)-  -> (V.Vector c -> [b]) -  -> UniqG a b -  -> [a] +  (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.+  -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. +  -> Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed.+  -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left.+  -> Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file.+  -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently.+  -> ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module.+  -> (V.Vector c -> [b])  -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result.+  -> UniqG a b -- ^ A parameter to control the behaviour of the function. The data constructor (either 'U' or 'UL') is preserved.+  -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text.     -> IO (UniqG a b) uniqNPoetical2VGN whspss rr n k info vN g1 g2 y xs  | n <= 0 = if isU y then return (U V.empty) else return (UL ([],V.empty))
uniqueness-periods-vector-general.cabal view
@@ -2,7 +2,7 @@ --   For further documentation, see http://haskell.org/cabal/users-guide/  name:                uniqueness-periods-vector-general-version:             0.2.0.0+version:             0.2.0.1 synopsis:            Generalization of the functionality of the dobutokO-poetry-general-languages package description:         Generalization of the functionality of the dobutokO-poetry-general-languages package homepage:            https://hackage.haskell.org/package/uniqueness-periods-vector-general