phonetic-languages-constraints 0.3.2.0 → 0.4.0.0
raw patch · 4 files changed
+38/−30 lines, 4 filesdep +subGdep +subG-instancesdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: subG, subG-instances
Dependency ranges changed: base
API changes (from Hackage documentation)
- Languages.UniquenessPeriods.Vector.Constraints: filterOrderIJ :: Int -> Int -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints: filterOrderIJ :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => Int -> Int -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints: unsafeQuadruples :: Int -> Int -> Int -> Int -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints: unsafeQuadruples :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => Int -> Int -> Int -> Int -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints: unsafeSeveralA :: Int -> Vector Int -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints: unsafeSeveralA :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => Int -> Vector Int -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints: unsafeSeveralB :: Int -> Vector Int -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints: unsafeSeveralB :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => Int -> Vector Int -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints: unsafeTriples :: Int -> Int -> Int -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints: unsafeTriples :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => Int -> Int -> Int -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints.Encoded: decodeConstraint1 :: EncodedCnstrs -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints.Encoded: decodeConstraint1 :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => EncodedCnstrs -> t (Vector Int) -> t (Vector Int)
- Languages.UniquenessPeriods.Vector.Constraints.Encoded: decodeLConstraints :: [EncodedCnstrs] -> Vector (Vector Int) -> Vector (Vector Int)
+ Languages.UniquenessPeriods.Vector.Constraints.Encoded: decodeLConstraints :: (InsertLeft t (Vector Int), Monoid (t (Vector Int))) => [EncodedCnstrs] -> t (Vector Int) -> t (Vector Int)
Files
- CHANGELOG.md +4/−1
- Languages/UniquenessPeriods/Vector/Constraints.hs +26/−23
- Languages/UniquenessPeriods/Vector/Constraints/Encoded.hs +5/−3
- phonetic-languages-constraints.cabal +3/−3
CHANGELOG.md view
@@ -10,5 +10,8 @@ ## 0.3.2.0 -- 2020-11-12 -* Third version revised C. Fixed issue with inner unneeded sorting and nubbing in the readMaybeEC function. +* Third version revised C. Fixed issue with inner unneeded sorting and nubbing in the readMaybeEC function. +## 0.4.0.0 -- 2020-11-26++* Fourth version. Switched to more general subG functionality using InsertLeft class and instances. Added, therefore, additional dependencies.
Languages/UniquenessPeriods/Vector/Constraints.hs view
@@ -6,18 +6,18 @@ -- Maintainer : olexandr543@yahoo.com -- -- Provides several the most important variants of constraints for the--- 'VB.Vector' of 'VB.Vector' 'Int' that are permutations. All the 'VB.Vector'+-- permutations. All the 'VB.Vector' -- here must consists of unique 'Int' starting from 0 to n and the 'Int' -- arguments must be in the range [0..n] though these inner constraints are -- not checked. It is up to user to check them. -- -{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE BangPatterns, FlexibleContexts #-} module Languages.UniquenessPeriods.Vector.Constraints ( -- * Basic predicate unsafeOrderIJ- -- * Functions to work with permutations with basic constraints+ -- * Functions to work with permutations with basic constraints ('VB.Vector'-based) , filterOrderIJ , unsafeTriples , unsafeQuadruples@@ -28,51 +28,54 @@ import qualified Data.Vector as VB import Data.Maybe (fromJust)+import Data.SubG (InsertLeft(..),filterG)+import Data.SubG.InstancesPlus -- | Being given the data satisfying the constraints in the module header checks whether in the 'VB.Vector' the first argument stands before the second one. unsafeOrderIJ :: Int -> Int -> VB.Vector Int -> Bool unsafeOrderIJ i j v = fromJust (VB.findIndex (== i) v) < fromJust (VB.findIndex (== j) v) -- | Being given the data satisfying the constraints in the module header returns the elements that satisfy 'unsafeOrderIJ' as a predicate.-filterOrderIJ :: Int -> Int -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)-filterOrderIJ i j = VB.filter (unsafeOrderIJ i j)+filterOrderIJ :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => Int -> Int -> t (VB.Vector Int) -> t (VB.Vector Int)+filterOrderIJ i j = filterG (unsafeOrderIJ i j) --- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the 'VB.Vector' of+-- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of -- the permutations each one being represented as 'VB.Vector' 'Int' where 'Int' are all the numbers in the range [0..n] without duplication if the -- arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line. -- The first three arguments -- are the indices of the the triple duplicated elements (words or their concatenated combinations in the @phonetic-languages@ series of packages).-unsafeTriples :: Int -> Int -> Int -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)-unsafeTriples i j k = VB.filter (\v -> unsafeOrderIJ i j v && unsafeOrderIJ j k v)+unsafeTriples :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => Int -> Int -> Int -> t (VB.Vector Int) -> t (VB.Vector Int)+unsafeTriples i j k = filterG (\v -> unsafeOrderIJ i j v && unsafeOrderIJ j k v) --- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the 'VB.Vector' of+-- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of -- the permutations each one being represented as 'VB.Vector' 'Int' where 'Int' are all the numbers in the range [0..n] without duplication if the -- arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line. -- The first four arguments -- are the indices of the the quadruple duplicated elements (words or their concatenated combinations in the @phonetic-languages@ series of packages).-unsafeQuadruples :: Int -> Int -> Int -> Int -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)-unsafeQuadruples i j k l = VB.filter (\v -> unsafeOrderIJ i j v && unsafeOrderIJ j k v && unsafeOrderIJ k l v)+unsafeQuadruples :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => Int -> Int -> Int -> Int -> t (VB.Vector Int) -> t (VB.Vector Int)+unsafeQuadruples i j k l = filterG (\v -> unsafeOrderIJ i j v && unsafeOrderIJ j k v && unsafeOrderIJ k l v) --- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the 'VB.Vector' of+-- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of -- the permutations each one being represented as 'VB.Vector' 'Int' where 'Int' are all the numbers in the range [0..n] without duplication.--- The first argument+-- The first (VB.Vector Int)rgument -- is the index of the the element (a word or their concatenated combination in the @phonetic-languages@ series of packages), the second argument--- is 'VB.Vector' of indices that are in the range [0..n]. Filters (and reduces further complex computtions) the permutations so that only the--- variants with the indices in the second argument all stand AFTER the element with the index equal to the first argument.-unsafeSeveralA :: Int -> VB.Vector Int -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)+-- is 'VB.Vector' of indices that (VB.Vector Int)re in the range [0..n]. Filters (and reduces further complex computtions) the permutations so that only the+-- variants with the indices in the second argument (VB.Vector Int)ll stand AFTER the element with the index equal to the first (VB.Vector Int)rgument.+unsafeSeveralA :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => Int -> VB.Vector Int -> t (VB.Vector Int) -> t (VB.Vector Int) unsafeSeveralA !i0 v1 v2 = let j !i !v = fromJust (VB.findIndex (== i) v) in- VB.filter (\v -> g i0 j v v1) v2+ filterG (\v -> g i0 j v v1) v2 where g !i j !v v3 = VB.all (> j i v) . VB.findIndices (`VB.elem` v3) $ v --- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the 'VB.Vector' of+-- | Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of -- the permutations each one being represented as 'VB.Vector' 'Int' where 'Int' are all the numbers in the range [0..n] without duplication.--- The first argument+-- The first (VB.Vector Int)rgument -- is the index of the the element (a word or their concatenated combination in the @phonetic-languages@ series of packages), the second argument--- is 'VB.Vector' of indices that are in the range [0..n]. Filters (and reduces further complex computtions) the permutations so that only the--- variants with the indices in the second argument all stand BEFORE the element with the index equal to the first argument.-unsafeSeveralB :: Int -> VB.Vector Int -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)+-- is 'VB.Vector' of indices that (VB.Vector Int)re in the range [0..n]. Filters (and reduces further complex computtions) the permutations so that only the+-- variants with the indices in the second argument (VB.Vector Int)ll stand BEFORE the element with the index equal to the first (VB.Vector Int)rgument.+unsafeSeveralB :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => Int -> VB.Vector Int -> t (VB.Vector Int) -> t (VB.Vector Int) unsafeSeveralB !i0 v1 v2 = let j !i !v = fromJust (VB.findIndex (== i) v) in- VB.filter (\v -> g i0 j v v1) v2+ filterG (\v -> g i0 j v v1) v2 where g !i j !v v3 = VB.all (< j i v) . VB.findIndices (`VB.elem` v3) $ v+
Languages/UniquenessPeriods/Vector/Constraints/Encoded.hs view
@@ -8,7 +8,7 @@ -- Provides a way to encode the needed constraint with possibly less symbols. -- -{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleInstances, FlexibleContexts #-} module Languages.UniquenessPeriods.Vector.Constraints.Encoded ( -- * Data types@@ -39,6 +39,8 @@ import qualified Data.Vector as VB --import Data.List import Languages.UniquenessPeriods.Vector.Constraints+import Data.SubG (InsertLeft(..))+import Data.SubG.InstancesPlus data EncodedContraints a b = E a | Q a a a a a | T a a a a | SA a a b | SB a a b | F a a a deriving (Eq, Ord) @@ -113,7 +115,7 @@ -- | Must be applied to the correct vector of permutation indeces. Otherwise, it gives runtime error (exception). All the integers inside the -- 'EncodedCnstrs' must be in the range [0..n] where @n@ corresponds to the maximum element in the permutation 'VB.Vector' 'Int'. Besides, -- @n@ is (probably must be) not greater than 6.-decodeConstraint1 :: EncodedCnstrs -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)+decodeConstraint1 :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => EncodedCnstrs -> t (VB.Vector Int) -> t (VB.Vector Int) decodeConstraint1 (E _) = id decodeConstraint1 (Q _ i j k l) = unsafeQuadruples i j k l decodeConstraint1 (T _ i j k) = unsafeTriples i j k@@ -124,7 +126,7 @@ -- | Must be applied to the correct vector of permutation indeces. Otherwise, it gives runtime error (exception). All the integers inside the -- 'EncodedCnstrs' must be in the range [0..n] where @n@ corresponds to the maximum element in the permutation 'VB.Vector' 'Int'. Besides, -- @n@ is (probably must be) not greater than 6.-decodeLConstraints :: [EncodedCnstrs] -> VB.Vector (VB.Vector Int) -> VB.Vector (VB.Vector Int)+decodeLConstraints :: (InsertLeft t (VB.Vector Int), Monoid (t (VB.Vector Int))) => [EncodedCnstrs] -> t (VB.Vector Int) -> t (VB.Vector Int) decodeLConstraints (x:xs) = decodeLConstraints' ys . decodeConstraint1 y where y = minimum (x:xs) ys = filter (/= y) . g $ (x:xs)
phonetic-languages-constraints.cabal view
@@ -2,7 +2,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: phonetic-languages-constraints-version: 0.3.2.0+version: 0.4.0.0 synopsis: Constraints to filter the needed permutations description: Provides several the most important variants of constraints. Can be used with the phonetic-languages-common series of package. homepage: https://hackage.haskell.org/package/phonetic-languages-constraints@@ -19,7 +19,7 @@ library exposed-modules: Languages.UniquenessPeriods.Vector.Constraints, Languages.UniquenessPeriods.Vector.Constraints.Encoded -- other-modules:- other-extensions: BangPatterns, FlexibleInstances- build-depends: base >=4.7 && <4.15, vector >=0.11 && <0.14+ other-extensions: BangPatterns, FlexibleInstances, FlexibleContexts+ build-depends: base >=4.8 && <4.15, vector >=0.11 && <0.14, subG >= 0.4.2 && <1, subG-instances >= 0.1 && <1 -- hs-source-dirs: default-language: Haskell2010