uniqueness-periods-vector-common 0.4.1.0 → 0.5.0.0
raw patch · 4 files changed
+34/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Languages.UniquenessPeriods.Vector.Data: D2 :: (a -> b) -> (b -> c) -> FuncRep a b c
+ Languages.UniquenessPeriods.Vector.Data: U1 :: (a -> c) -> FuncRep a b c
+ Languages.UniquenessPeriods.Vector.Data: data FuncRep a b c
+ Languages.UniquenessPeriods.Vector.Data: getAC :: FuncRep a b c -> a -> c
+ Languages.UniquenessPeriods.Vector.Data: isD2 :: FuncRep a b c -> Bool
+ Languages.UniquenessPeriods.Vector.Data: isU1 :: FuncRep a b c -> Bool
- Languages.UniquenessPeriods.Vector.StrictV: uniquenessVariants2GN :: (Eq a, Ord b) => [a] -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> [a] -> Vector ([b], Vector b, [a])
+ Languages.UniquenessPeriods.Vector.StrictV: uniquenessVariants2GN :: (Eq a, Ord b) => [a] -> Vector ([b] -> b) -> FuncRep [a] (Vector c) [b] -> [a] -> Vector ([b], Vector b, [a])
- Languages.UniquenessPeriods.Vector.StrictV: uniquenessVariants2GNP :: (Eq a, Ord b) => [a] -> [a] -> [a] -> Vector ([b] -> b) -> ([a] -> Vector c) -> (Vector c -> [b]) -> [a] -> Vector ([b], Vector b, [a])
+ Languages.UniquenessPeriods.Vector.StrictV: uniquenessVariants2GNP :: (Eq a, Ord b) => [a] -> [a] -> [a] -> Vector ([b] -> b) -> FuncRep [a] (Vector c) [b] -> [a] -> Vector ([b], Vector b, [a])
Files
- ChangeLog.md +5/−0
- Languages/UniquenessPeriods/Vector/Data.hs +22/−6
- Languages/UniquenessPeriods/Vector/StrictV.hs +6/−7
- uniqueness-periods-vector-common.cabal +1/−1
ChangeLog.md view
@@ -20,3 +20,8 @@ ## 0.4.1.0 -- 2020-10-06 * Fourth version revised A. Fixed issue with being concatenated lists without whitespaces in the Languages.UniquenessPeriods.Vector.StrictV.uniquenessVariants2GNP function.++## 0.5.0.0 -- 2020-10-09++* Fifth version. Added a new data type FuncRep a b c to Languages.UniquenessPeriods.Vector.Data module to avoid significant code duplication with further usage. Switched the +needed functionality to the new data type variant.
Languages/UniquenessPeriods/Vector/Data.hs view
@@ -5,9 +5,9 @@ -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com ----- Is a generalization of the DobutokO.Poetry.Data module --- functionality from the @dobutokO-poetry-general@ package. --- +-- Is a generalization of the DobutokO.Poetry.Data module+-- functionality from the @dobutokO-poetry-general@ package.+-- {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} @@ -19,7 +19,7 @@ type UniquenessG1 a b = ([b],V.Vector b,[a]) --- | The list in the 'PA' variant represent the prepending @[a]@ and the postpending one respectively. 'K' constuctor actually means no prepending and +-- | The list in the 'PA' variant represent the prepending @[a]@ and the postpending one respectively. 'K' constuctor actually means no prepending and -- postpending (usually of the text). Are used basically to control the behaviour of the functions. data PreApp a = K | PA [a] [a] deriving Eq @@ -31,7 +31,7 @@ getm _ = get2m preapp :: a -> [[b]] -> [[b]] setm :: [b] -> [b] -> a- + instance Eq a => UGG1 (PreApp a) a where get1m K = [] get1m (PA xs _) = xs@@ -57,7 +57,23 @@ instance (Show a, Show b) => Show (UniquenessG2 (UniquenessG1 a b) (V.Vector (UniquenessG1 a b))) where show (UL2 (ws,_)) = show ws -type UniqG2 a b = UniquenessG2 (UniquenessG1 a b) (V.Vector (UniquenessG1 a b)) +type UniqG2 a b = UniquenessG2 (UniquenessG1 a b) (V.Vector (UniquenessG1 a b)) get22 :: UniqG2 a b -> ([UniquenessG1 a b], V.Vector (UniquenessG1 a b)) get22 (UL2 (ws, x)) = (ws, x)++-- | Is used to avoid significant code duplication.+data FuncRep a b c = U1 (a -> c) | D2 (a -> b) (b -> c)++getAC :: FuncRep a b c -> (a -> c)+getAC (U1 f) = f+getAC (D2 g1 g2) = g2 . g1++isU1 :: FuncRep a b c -> Bool+isU1 (U1 _) = True+isU1 _ = False++isD2 :: FuncRep a b c -> Bool+isD2 (D2 _ _) = True+isD2 _ = False+
Languages/UniquenessPeriods/Vector/StrictV.hs view
@@ -24,6 +24,7 @@ #endif import qualified Data.Vector as V import qualified Data.List as L (permutations,intercalate)+import Languages.UniquenessPeriods.Vector.Data -- | 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@@ -35,11 +36,10 @@ uniquenessVariants2GN :: (Eq a, Ord b) => [a] -> V.Vector ([b] -> b)- -> ([a] -> V.Vector c)- -> (V.Vector c -> [b])+ -> FuncRep [a] (V.Vector c) [b] -- ^ Since version 0.5.0.0 it includes the previous variant with data constructor 'D2', but additionally allows to use just single argument with data constructor 'U1' -> [a] -> V.Vector ([b],V.Vector b, [a])-uniquenessVariants2GN whspss vN g1 g2 !xs = uniquenessVariants2GNP [] [] whspss vN g1 g2 xs+uniquenessVariants2GN whspss vN frep !xs = uniquenessVariants2GNP [] [] whspss vN frep xs {-# INLINE uniquenessVariants2GN #-} -- | Generalized variant of 'uniquenessVariants2GN' with prepending and appending @[a]@ (given as the first and the second argument).@@ -48,14 +48,13 @@ -> [a] -> [a] -> V.Vector ([b] -> b)- -> ([a] -> V.Vector c)- -> (V.Vector c -> [b])+ -> FuncRep [a] (V.Vector c) [b] -- ^ Since version 0.5.0.0 it includes the previous variant with data constructor 'D2', but additionally allows to use just single argument with data constructor 'U1' -> [a] -> V.Vector ([b],V.Vector b, [a])-uniquenessVariants2GNP !ts !us whspss vN g1 g2 !xs+uniquenessVariants2GNP !ts !us whspss vN frep !xs | null . sublistsG whspss $ xs = V.empty | 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)) . L.intercalate [hd] . preAppend ts [us]) .+ V.fromList . map ((\vs -> let !rs = getAC frep $ vs in (rs, (V.map (\f -> f rs) vN), vs)) . L.intercalate [hd] . preAppend ts [us]) . L.permutations . map (hd:) $ ns | otherwise = error "Languages.UniquenessPeriods.Vector.StrictV.uniquenessVariants2GNP: undefined for the empty third argument. "
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.4.1.0+version: 0.5.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