packages feed

uniqueness-periods-vector-general 0.1.0.0 → 0.2.0.0

raw patch · 3 files changed

+74/−33 lines, 3 filesdep +print-infodep −uniqueness-periods-vectorPVP ok

version bump matches the API change (PVP)

Dependencies added: print-info

Dependencies removed: uniqueness-periods-vector

API changes (from Hackage documentation)

+ Languages.UniquenessPeriods.Vector.General.Debug: printHelp :: (Show a, Show b) => Info2 -> UniquenessG1 a b -> IO ()
+ Languages.UniquenessPeriods.Vector.General.Debug: toFile :: String -> [String] -> IO ()
- Languages.UniquenessPeriods.Vector.General.Debug: inner1 :: (Eq a, Ord b, Show a, Show b) => Int -> Vector ([b] -> b) -> UniqG a b -> IO ([b], UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: inner1 :: (Eq a, Ord b, Show a, Show b) => Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO ([b], UniqG a b)
- Languages.UniquenessPeriods.Vector.General.Debug: uniqInMaxPoeticalN :: (Eq a, Ord b, Show a, Show b) => Int -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqInMaxPoeticalN :: (Eq a, Ord b, Show a, Show b) => Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
- Languages.UniquenessPeriods.Vector.General.Debug: uniqInMaxPoeticalNL :: (Eq a, Ord b, Show a, Show b) => Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqInMaxPoeticalNL :: (Eq a, Ord b, Show a, Show b) => Info2 -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoetical2GN :: (Eq a, Ord b, Show a, Show b) => [a] -> Preapp a -> Int -> Int -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> [a] -> IO ()
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoetical2GN :: (Eq a, Ord b, Show a, Show b) => [a] -> Preapp a -> Int -> Int -> Info2 -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> [a] -> IO ()
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoetical2VGN :: (Eq a, Ord b, Show a, Show b) => [a] -> Preapp a -> Int -> Int -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> UniqG a b -> [a] -> IO (UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoetical2VGN :: (Eq a, Ord b, Show a, Show b) => [a] -> Preapp a -> Int -> Int -> Info2 -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> UniqG a b -> [a] -> IO (UniqG a b)
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalN :: (Eq a, Ord b, Show a, Show b) => Int -> Int -> Vector ([b] -> b) -> UniqG a b -> IO ()
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalN :: (Eq a, Ord b, Show a, Show b) => Int -> Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO ()
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalNL :: (Eq a, Ord b, Show a, Show b) => Int -> Vector ([b] -> b) -> UniqG a b -> IO ()
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalNL :: (Eq a, Ord b, Show a, Show b) => Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO ()
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalVN :: (Eq a, Ord b, Show a, Show b) => Int -> Int -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalVN :: (Eq a, Ord b, Show a, Show b) => Int -> Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
- Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalVNL :: (Eq a, Ord b, Show a, Show b) => Int -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)
+ Languages.UniquenessPeriods.Vector.General.Debug: uniqNPoeticalVNL :: (Eq a, Ord b, Show a, Show b) => Int -> Info2 -> Vector ([b] -> b) -> UniqG a b -> IO (UniqG a b)

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for uniqueness-periods-vector-general -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.0.0 -- 2020-08-31  * First version. Released on an unsuspecting world.++## 0.2.0.0 -- 2020-09-01++* 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.
Languages/UniquenessPeriods/Vector/General/Debug.hs view
@@ -11,15 +11,13 @@ module Languages.UniquenessPeriods.Vector.General.Debug where  import Data.Maybe (fromJust)-import Data.Char (isPunctuation)+import Data.Print.Info+import System.IO import qualified Data.Vector as V import Languages.UniquenessPeriods.Vector.Auxiliary-import String.Languages.UniquenessPeriods.Vector import Languages.UniquenessPeriods.Vector.StrictV import Languages.UniquenessPeriods.Vector.Data -- -- |  uniqMaxPoeticalGNV ::    (Eq a, Ord b) => Int @@ -36,18 +34,54 @@  | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . snd . get2 $ y {-# INLINE uniqMaxPoeticalGNV #-} +-- | Inspired by appendS16LEFile function from Melodics.Ukrainian module from @mmsyn6ukr@ package.+toFile :: String -> [String] -> IO ()+toFile file xss = withFile file AppendMode (\hdl -> do+    hClose hdl+    closedHdl <- hIsClosed hdl+    if closedHdl +      then openFile file AppendMode >>= \hdl -> mapM_ (hPutStrLn hdl) xss+      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.+printHelp +  :: (Show a, Show b) => Info2 +  -> UniquenessG1 a b+  -> IO ()+printHelp info uni +  | isI1 info = +      case (\(I1 x) -> x) info of +        A -> putStr "" -- nothing is printed+        B -> mapM_ putStrLn [show . lastFrom3 $ uni]+        C -> mapM_ putStrLn [show . firstFrom3 $ uni]+        D -> mapM_ putStrLn [show . secondFrom3 $ uni]+        E -> mapM_ putStrLn [show . lastFrom3 $ uni, show . firstFrom3 $ uni]+        F -> mapM_ putStrLn [show . lastFrom3 $ uni, show . secondFrom3 $ uni]+        G -> mapM_ putStrLn [show . firstFrom3 $ uni, show . secondFrom3 $ uni]+        _ -> mapM_ putStrLn [show . lastFrom3 $ uni, show . firstFrom3 $ uni, show. secondFrom3 $ uni]  -- the most verbose output+  | otherwise =+      case (\(I2 x) -> x) info of +        Af xs -> putStr "" -- nothing is printed+        Bf xs -> toFile xs [show . lastFrom3 $ uni]+        Cf xs -> toFile xs [show . firstFrom3 $ uni]+        Df xs -> toFile xs [show . secondFrom3 $ uni]+        Ef xs -> toFile xs [show . lastFrom3 $ uni, show . firstFrom3 $ uni]+        Ff xs -> toFile xs [show . lastFrom3 $ uni, show . secondFrom3 $ uni]+        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+ -- |  inner1 ::    (Eq a, Ord b, Show a, Show b) => Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b    -> IO ([b],UniqG a b)-inner1 k vN x = do +inner1 k info vN x = do    let uniq = uniqMaxPoeticalGNV k vN x   let fsT = (\(ys,_,_) -> ys) uniq-  putStrLn . show . lastFrom3 $ uniq-  putStrLn . show . firstFrom3 $ uniq-  putStrLn . show . secondFrom3 $ uniq+  printHelp info uniq   return (fsT,x) {-# INLINE inner1 #-} @@ -94,11 +128,12 @@ -- |  uniqInMaxPoeticalN ::    (Eq a, Ord b, Show a, Show b) => Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b    -> IO (UniqG a b)-uniqInMaxPoeticalN k vN x = do-  inner1 k vN x >>= \(fsT,x) -> +uniqInMaxPoeticalN k info vN x = do+  inner1 k info vN x >>= \(fsT,x) ->      if isU x then return (U (V.filter (\(xs,_,_) -> xs /= fsT) . snd . get2 $ x))     else return (UL ((\(v1,v2) -> ((V.toList . V.map lastFrom3 $ v1) ++ (fromJust . fst . get2 $ x),v2)) .        V.unstablePartition (\(xs,_,_) -> xs == fsT) . snd . get2 $ x))@@ -106,55 +141,57 @@    -- |  uniqInMaxPoeticalNL :: -  (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) +  (Eq a, Ord b, Show a, Show b) => Info2 +  -> V.Vector ([b] -> b)    -> UniqG a b    -> IO (UniqG a b)-uniqInMaxPoeticalNL vN = uniqInMaxPoeticalN (V.length vN) vN+uniqInMaxPoeticalNL info vN = uniqInMaxPoeticalN (V.length vN) info vN {-# INLINE uniqInMaxPoeticalNL #-}  -- |  uniqNPoeticalN ::    (Eq a, Ord b, Show a, Show b) => Int    -> Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b -> IO ()-uniqNPoeticalN n k vN y  +uniqNPoeticalN n k info vN y    | n <= 0 = return ()- | compare (V.length . snd . get2 $ y) n == LT = V.mapM_ (\x -> do -   { putStrLn . show . lastFrom3 $ x-   ; putStrLn . show . firstFrom3 $ x-   ; putStrLn . show . secondFrom3 $ x}) . snd . get2 $ y- | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalN (n - 1) k vN)+ | 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 #-}  -- |  uniqNPoeticalNL ::    (Eq a, Ord b, Show a, Show b) => Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b    -> IO ()-uniqNPoeticalNL n vN = uniqNPoeticalN n (V.length vN) vN+uniqNPoeticalNL n info vN = uniqNPoeticalN n (V.length vN) info vN {-# INLINE uniqNPoeticalNL #-}  -- |  uniqNPoeticalVN ::    (Eq a, Ord b, Show a, Show b) => Int    -> Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b    -> IO (UniqG a b)-uniqNPoeticalVN n k vN y+uniqNPoeticalVN n k info vN y  | n <= 0 || compare (V.length . snd . get2 $ y) n == LT = return y- | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalVN (n - 1) k vN)+ | otherwise = (uniqInMaxPoeticalN k info vN y >>= uniqNPoeticalVN (n - 1) k info vN) {-# INLINE uniqNPoeticalVN #-}  -- |  uniqNPoeticalVNL ::    (Eq a, Ord b, Show a, Show b) => Int +  -> Info2   -> V.Vector ([b] -> b)    -> UniqG a b    -> IO (UniqG a b)-uniqNPoeticalVNL n vN = uniqNPoeticalVN n (V.length vN) vN+uniqNPoeticalVNL n info vN = uniqNPoeticalVN n (V.length vN) info vN {-# INLINE uniqNPoeticalVNL #-}  --------------------------------------------------------------------------------------------@@ -165,21 +202,19 @@   -> Preapp a    -> Int    -> Int +  -> Info2   -> V.Vector ([b] -> b)    -> ([a] -> V.Vector c)   -> (V.Vector c -> [b])    -> [a]    -> IO ()-uniqNPoetical2GN whspss rr n k vN g1 g2 xs+uniqNPoetical2GN whspss rr n k info vN g1 g2 xs  | n <= 0 = return ()  | otherwise = do    let v = uniquenessVariants2GNP whspss (get1m rr) (get2m rr) vN g1 g2 xs    if compare (V.length v) n == LT-     then V.mapM_ (\x -> do -       { putStrLn . show . lastFrom3 $ x-       ; putStrLn . show . firstFrom3 $ x-       ; putStrLn . show . secondFrom3 $ x}) v-     else (uniqInMaxPoeticalN k vN (U v) >>= uniqNPoeticalN (n - 1) k vN)+     then V.mapM_ (printHelp info) v+     else (uniqInMaxPoeticalN k info vN (U v) >>= uniqNPoeticalN (n - 1) k info vN)  -- |  uniqNPoetical2VGN :: @@ -187,16 +222,17 @@   -> Preapp a    -> Int    -> Int +  -> Info2   -> V.Vector ([b] -> b)    -> ([a] -> V.Vector c)   -> (V.Vector c -> [b])    -> UniqG a b    -> [a]    -> IO (UniqG a b)-uniqNPoetical2VGN whspss rr n k vN g1 g2 y xs+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))  | otherwise = do    let v = uniquenessVariants2GNP whspss (get1m rr) (get2m rr) vN g1 g2 xs    if compare (V.length v) n == LT       then if isU y then return (U v) else return (UL ([],v)) -     else if isU y then uniqNPoeticalVN n k vN (U v) else uniqNPoeticalVN n k vN (UL ([],v))+     else if isU y then uniqNPoeticalVN n k info vN (U v) else uniqNPoeticalVN n k info vN (UL ([],v))
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.1.0.0+version:             0.2.0.0 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@@ -20,6 +20,6 @@   exposed-modules:     Languages.UniquenessPeriods.Vector.General.Debug   -- other-modules:   -- other-extensions:-  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector-common >=0.1 && <1, uniqueness-periods-vector >=0.1 && <1+  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector-common >=0.1 && <1, print-info >=0.1.3 && <1   -- hs-source-dirs:   default-language:    Haskell2010