packages feed

phonetic-languages-constraints-array 0.4.0.0 → 0.4.1.0

raw patch · 3 files changed

+39/−28 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Phladiprelio.ConstraintsEncoded: isM :: EncodedCnstrs -> Bool
- Phladiprelio.ConstraintsEncoded: H :: a -> a -> a -> EncodedContraints a b
+ Phladiprelio.ConstraintsEncoded: H :: a -> a -> a -> a -> EncodedContraints a b
- Phladiprelio.ConstraintsEncoded: M :: a -> a -> a -> EncodedContraints a b
+ Phladiprelio.ConstraintsEncoded: M :: a -> a -> a -> a -> EncodedContraints a b
- Phladiprelio.ConstraintsEncoded: R :: a -> a -> a -> EncodedContraints a b
+ Phladiprelio.ConstraintsEncoded: R :: a -> a -> a -> a -> EncodedContraints a b
- Phladiprelio.ConstraintsEncoded: V :: a -> a -> EncodedContraints a b
+ Phladiprelio.ConstraintsEncoded: V :: a -> a -> a -> EncodedContraints a b
- Phladiprelio.ConstraintsEncoded: W :: a -> a -> EncodedContraints a b
+ Phladiprelio.ConstraintsEncoded: W :: a -> a -> a -> EncodedContraints a b

Files

CHANGELOG.md view
@@ -27,3 +27,8 @@ * Fourth version. Added a new type of constraint based on both signed and unsigned distances between three elements (encoded with M). Some documentation improvements. +## 0.4.1.0 -- 2023-05-16++* Fourth version revised. Changed the number of parameters for the new constructors added. Added+isM function to the export from the module.+
Phladiprelio/ConstraintsEncoded.hs view
@@ -38,6 +38,7 @@   , isW   , isH   , isR+  , isM ) where  import GHC.Base@@ -50,7 +51,7 @@ import Phladiprelio.Constraints import Data.SubG (InsertLeft(..)) -data EncodedContraints a b = E a | P a b | Q a a a a a | T a a a a | SA a a b | SB a a b | F a a a | V a a | W a a | H a a a | R a a a | M a a a deriving (Eq, Ord)+data EncodedContraints a b = E a | P a b | Q a a a a a | T a a a a | SA a a b | SB a a b | F a a a | V a a a | W a a a | H a a a a | R a a a a | M a a a a deriving (Eq, Ord)  -- | Inspired by the: https://hackage.haskell.org/package/base-4.14.0.0/docs/Data-Maybe.html -- Is provided here as a more general way to read the 'String' into a 'EncodedCnstrs' than more restricted@@ -100,11 +101,11 @@           (_,_,_,Nothing) -> Nothing           ~(Just x1, Just x2, Just x3, Just x4) -> Just (Q undefined x1 x2 x3 x4)        'P' -> if null ts then Just (E 0) else let l = length ts in Just . P n . listArray (0,l-1) . map (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts-       'W' -> if length ts /= 2 then Just (E 0) else let [k,t] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . W k $ t-       'V' -> if length ts /= 2 then Just (E 0) else let [k,t] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . V k $ t-       'H' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . H k t $ w -       'R' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . R k t $ w -       'M' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . M k t $ w +       'W' -> if length ts /= 2 then Just (E 0) else let [k,t] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . W n k $ t+       'V' -> if length ts /= 2 then Just (E 0) else let [k,t] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . V n k $ t+       'H' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . H n k t $ w +       'R' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . R n k t $ w +       'M' -> if length ts /= 3 then Just (E 0) else let [k,t,w] = map  (\x -> case (fromJust (readMaybe [x]::Maybe Int)) of {0 -> 9; n -> n - 1}) $ ts in Just . M n k t $ w         _   -> Nothing  | otherwise = Nothing @@ -118,8 +119,13 @@ setWordsN n (Just (SA _ i v)) = Just (SA n i v) setWordsN n (Just (SB _ i v)) = Just (SB n i v) setWordsN n (Just (F _ i j)) = Just (F n i j)-setWordsN _ cnstr = cnstr+setWordsN n (Just (V _ i j)) = Just (V n i j)+setWordsN n (Just (W _ i j)) = Just (W n i j)+setWordsN n (Just (H _ i j k)) = Just (H n i j k)+setWordsN n (Just (R _ i j k)) = Just (R n i j k)+setWordsN n (Just (M _ i j k)) = Just (M n i j k) + -- | A safer variant of the 'readMaybeEC' more suitable for applications, e. g. for phonetic-languages series of packages. readMaybeECG :: Int -> String -> Maybe EncodedCnstrs readMaybeECG n xs@@ -139,11 +145,11 @@ decodeConstraint1 (SA _ i v) = unsafeSeveralA i v decodeConstraint1 (SB _ i v) = unsafeSeveralB i v decodeConstraint1 (F _ i j) = filterOrderIJ i j-decodeConstraint1 (V i j) = filterSignDistanceIJ i j (j - i)-decodeConstraint1 (W i j) = filterUnsignDistanceIJ i j (abs $ j - i)-decodeConstraint1 (H i j k) = filterSignDistanceIJK3 i j k (j - i) (k - j)-decodeConstraint1 (R i j k) = filterUnsignDistanceIJK3 i j k (abs (j - i)) (abs (k - j))-decodeConstraint1 (M i j k) = filterMixedDistanceIJK3 i j k (j - i) (abs (k - j))+decodeConstraint1 (V _ i j) = filterSignDistanceIJ i j (j - i)+decodeConstraint1 (W _ i j) = filterUnsignDistanceIJ i j (abs $ j - i)+decodeConstraint1 (H _ i j k) = filterSignDistanceIJK3 i j k (j - i) (k - j)+decodeConstraint1 (R _ i j k) = filterUnsignDistanceIJK3 i j k (abs (j - i)) (abs (k - j))+decodeConstraint1 (M _ i j k) = filterMixedDistanceIJK3 i j k (j - i) (abs (k - j))  -- | Must be applied to the correct array 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 'Array' 'Int' 'Int'. Besides,@@ -188,23 +194,23 @@ isSB _ = False  isV :: EncodedCnstrs -> Bool-isV (V _ _) = True+isV (V _ _ _) = True isV _ = False  isW :: EncodedCnstrs -> Bool-isW (W _ _) = True+isW (W _ _ _) = True isW _ = False  isH :: EncodedCnstrs -> Bool-isH (H _ _ _) = True+isH (H _ _ _ _) = True isH _ = False  isR :: EncodedCnstrs -> Bool-isR (R _ _ _) = True+isR (R _ _ _ _) = True isR _ = False  isM :: EncodedCnstrs -> Bool-isM (M _ _ _) = True+isM (M _ _ _ _) = True isM _ = False  @@ -218,11 +224,11 @@ getIEl (SA _ i _) = i getIEl (SB _ i _) = i getIEl (F _ i _) = i-getIEl (V i _) = i-getIEl (W i _) = i-getIEl (H i _ _) = i-getIEl (R i _ _) = i-getIEl (M i _ _) = i+getIEl (V _ i _) = i+getIEl (W _ i _) = i+getIEl (H _ i _ _) = i+getIEl (R _ i _ _) = i+getIEl (M _ i _ _) = i  {-| Works only with the correctly defined arguments though it is not checked. Use with this caution. -}@@ -234,9 +240,9 @@ setIEl i (SA n _ v) = SA n i v setIEl i (SB n _ v) = SB n i v setIEl i (F n _ j) = F n i j-setIEl i (V _ j) = V i j-setIEl i (W _ j) = W i j-setIEl i (H _ j k) = H i j k-setIEl i (R _ j k) = R i j k-setIEl i (M _ j k) = M i j k+setIEl i (V n _ j) = V n i j+setIEl i (W n _ j) = W n i j+setIEl i (H n _ j k) = H n i j k+setIEl i (R n _ j k) = R n i j k+setIEl i (M n _ j k) = M n i j k 
phonetic-languages-constraints-array.cabal view
@@ -2,7 +2,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/  name:                phonetic-languages-constraints-array-version:             0.4.0.0+version:             0.4.1.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. Instead of vectors, uses arrays. homepage:            https://hackage.haskell.org/package/phonetic-languages-constraints-array