packages feed

phonetic-languages-constraints-array 0.7.2.0 → 0.7.3.0

raw patch · 4 files changed

+142/−61 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Phladiprelio.Constraints: isQuintupleOrdered :: Int -> Int -> Int -> Int -> Int -> Array Int Int -> Bool
+ Phladiprelio.Constraints: notQuintupleOrdered :: Int -> Int -> Int -> Int -> Int -> Array Int Int -> Bool
+ Phladiprelio.Constraints: unsafeQuintuples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int)
+ Phladiprelio.ConstraintsEncoded: U :: a -> a -> a -> a -> a -> a -> EncodedContraints a b d
+ Phladiprelio.ConstraintsEncoded: isU :: EncodedCnstrs -> Bool

Files

CHANGELOG.md view
@@ -81,4 +81,8 @@ in the oneChange function definition that leads to incorrect behaviour of the parentheses handling. Some minor documentation and code improvements. +## 0.7.3.0 -- 2023-06-06++* Seventh version revised D. Added new constraint type U for five elements. Switched to bit+  algorithms in some functions (mostly for testing and more readable code).  
Phladiprelio/Constraints.hs view
@@ -29,6 +29,7 @@   , isMixedDistIJK3   , isTripleOrdered   , isQuadrupleOrdered+  , isQuintupleOrdered   , isSeveralAOrdered   , isSeveralBOrdered   , isFixedPointTup@@ -38,6 +39,7 @@   , notMixedDistIJK3    , notTripleOrdered    , notQuadrupleOrdered+  , notQuintupleOrdered   , notSeveralAOrdered    , notSeveralBOrdered    , notFixedPointTup @@ -46,6 +48,7 @@   , filterOrderIJ   , unsafeTriples   , unsafeQuadruples+  , unsafeQuintuples   -- ** With multiple elements specified   , unsafeSeveralA   , unsafeSeveralB@@ -61,24 +64,68 @@ ) where  import GHC.Base hiding (foldr)-import GHC.Num ((-),(+))-import Data.Maybe (fromJust)+import GHC.Num (Num, (-),(+)) import Data.SubG (InsertLeft(..),filterG) import GHC.Arr-import Data.Foldable (all, foldr, any)+import GHC.Int (Int8(..))+import Data.Bits ((.&.),testBit, shiftR, setBit, clearBit)+import Data.Foldable (Foldable, all, foldr, any) +f2 :: (Foldable t, Eq p) => p -> p -> t p -> Int8+f2 i j = foldr g (0::Int8) -- (== 3)+  where g x y+          | y == 3 = 3+          | x == j = bitChange (shiftR y 1 == 0) y 0+          | x == i = bitChange (testBit y 0) y 1+          | otherwise = y+{-# INLINE f2 #-}++f3 :: (Foldable t, Eq p) => p -> p -> p -> t p -> Int8+f3 i j k = foldr g (0::Int8) -- (== 7)+  where g x y+          | y == 7 = 7+          | x == k = bitChange (shiftR y 1 == 0) y 0  -- u, not (t && u))+          | x == j = bitChange (not (testBit y 2) && testBit y 0) y 1  -- (t, w && not t, w)+          | x == i = bitChange (clearBit y 2 == 3) y 2  -- (u && w, u, w)+          | otherwise = y+{-# INLINE f3 #-}++f4 :: (Foldable t, Eq p) => p -> p -> p -> p -> t p -> Int8+f4 i j k l = foldr g (0::Int8) -- (== 15)+  where g x y+          | y == 15 = 15+          | x == l = bitChange (shiftR y 1 == 0) y 0 +          | x == k = bitChange (shiftR y 2 == 0 && testBit y 0) y 1 +          | x == j = bitChange (not (testBit y 3) && y .&. 3 == 3) y 2  +          | x == i = bitChange (clearBit y 3 == 7) y 3 +          | otherwise = y+{-# INLINE f4 #-}++f5 :: (Foldable t, Eq p) => p -> p -> p -> p -> p -> t p -> Int8+f5 i j k l m = foldr g (0::Int8) -- (== 31)+  where g x y+          | y == 31 = 31+          | x == m = bitChange (shiftR y 1 == 0) y 0 +          | x == l = bitChange (testBit y 0 && shiftR y 2 == 0) y 1+          | x == k = bitChange (shiftR y 3 == 0 && y .&. 3 == 3) y 2 +          | x == j = bitChange (not (testBit y 4) && y .&. 7 == 7) y 3  +          | x == i = bitChange (clearBit y 4 == 15) y 4 +          | otherwise = y+{-# INLINE f5 #-}+--+-- | @n@ must be in the range [0..7] though it is not checked here.+bitChange + :: Bool + -> Int8 + -> Int + -> Int8+bitChange bool = (if bool then setBit else clearBit)+{-# INLINE bitChange #-}++ -- | Being given the data satisfying the constraints in the module header checks whether in the 'Array' the first argument stands before the second one. unsafeOrderIJ :: Int -> Int -> Array Int Int -> Bool-unsafeOrderIJ i j = (\(_,_,r) -> if r == 0 then True else False) . foldr helpG (j,i,0)--helpG z (t,u,n)-  | z == t = (t,u,1)-  | z == u =-     case n of-      0 -> (t,u,2)-      _ -> (t,u,n - 1)-  | otherwise = (t,u,n)-{-# INLINE helpG #-}+unsafeOrderIJ i j = (== 3) . f2 i j  -- | Being given the data satisfying the constraints in the module header checks whether in the -- 'Array' the distance between positions of the first two arguments values is equal to the signed@@ -91,7 +138,7 @@   -> Bool unsafeSignDistanceIJ i j d = (\(_,_,r) -> if r > 100 then (100 - r) == d else r == d) . foldr helpG2 (j, i, -1) -+helpG2 :: (Ord a1, Ord a2, Num a1, Num a2) => a2 -> (a2, a2, a1) -> (a2, a2, a1) helpG2 z (t, u, n)   | n < 0 = if (z /= t && z /= u) then (t, u, n) else (t, u, if z == t then 1 else 101)   | z /= u && z /= t && t >= 0 = (t, u, n + 1)@@ -109,6 +156,7 @@   -> Bool unsafeUnsignDistanceIJ i j d = (\(_,_,r) -> r == d) . foldr helpG3 (j, i, -1) +helpG3 :: (Ord a1, Ord a2, Num a1, Num a2) => a2 -> (a2, a2, a1) -> (a2, a2, a1) helpG3 z (t, u, n)   | n < 0 = if (z /= t && z /= u) then (t, u, n) else (t, u, 1)   | z /= u && z /= t && t >= 0 = (t, u, n + 1)@@ -140,21 +188,29 @@  -- | 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 'Array' 'Int' 'Int' where the elements are all the numbers in the range [0..n-1] without duplication if the--- arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line.+-- arguments are the indices 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).+-- can be the indices of the the triple duplicated elements (words or their concatenated combinations in the @phonetic-languages@ series of packages). unsafeTriples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) unsafeTriples i j k = filterG (isTripleOrdered i j k)  -- | 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 'Array' 'Int' 'Int' where the elements are all the numbers in the range [0..n-1] without duplication if the--- arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line.+-- arguments are the indices 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).+-- can the indices of the the quadruple duplicated elements (words or their concatenated combinations in the @phonetic-languages@ series of packages). unsafeQuadruples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) unsafeQuadruples i j k l = filterG (isQuadrupleOrdered i j k l)  -- | 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 'Array' 'Int' 'Int' where the elements are all the numbers in the range [0..n-1] without duplication if the+-- arguments are the indices of the duplicated words or their concatenated combinations in the corresponding line.+-- The first five arguments+-- can be the indices of the the quintuple duplicated elements (words or their concatenated combinations in the @phonetic-languages@ series of packages).+unsafeQuintuples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int ->  t (Array Int Int) -> t (Array Int Int)+unsafeQuintuples i j k l m = filterG (isQuintupleOrdered i j k l m)++-- | 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 'Array' 'Int' 'Int' where the elements are all the numbers in the range [0..n-1] without duplication. -- The first argument -- is the index of the the element (a word or their concatenated combination in the @phonetic-languages@ series of packages), the second argument@@ -200,13 +256,17 @@ {-# INLINE isMixedDistIJK3 #-}  isTripleOrdered :: Int -> Int -> Int -> Array Int Int -> Bool-isTripleOrdered i j k arr = unsafeOrderIJ i j arr && unsafeOrderIJ j k arr+isTripleOrdered i j k = (== 7) . f3 i j k {-# INLINE isTripleOrdered #-}  isQuadrupleOrdered :: Int -> Int -> Int -> Int -> Array Int Int -> Bool-isQuadrupleOrdered i j k l arr = unsafeOrderIJ i j arr && unsafeOrderIJ j k arr && unsafeOrderIJ k l arr+isQuadrupleOrdered i j k l = (== 15) . f4 i j k l {-# INLINE isQuadrupleOrdered #-} +isQuintupleOrdered :: Int -> Int -> Int -> Int -> Int -> Array Int Int -> Bool+isQuintupleOrdered i j k l m = (== 31) . f5 i j k l m+{-# INLINE isQuintupleOrdered #-}+ isSeveralAOrdered :: Int -> Array Int Int -> Array Int Int -> Bool isSeveralAOrdered !i0 !arr1 arr2 = all (\k -> unsafeOrderIJ i0 k arr2) arr1 {-# INLINE isSeveralAOrdered #-}@@ -236,12 +296,16 @@ {-# INLINE notMixedDistIJK3 #-}  notTripleOrdered :: Int -> Int -> Int -> Array Int Int -> Bool-notTripleOrdered i j k arr = unsafeOrderIJ j i arr || unsafeOrderIJ k j arr+notTripleOrdered i j k = (/= 7) . f3 i j k {-# INLINE notTripleOrdered #-}  notQuadrupleOrdered :: Int -> Int -> Int -> Int -> Array Int Int -> Bool-notQuadrupleOrdered i j k l arr = unsafeOrderIJ j i arr || unsafeOrderIJ k j arr || unsafeOrderIJ l k arr+notQuadrupleOrdered i j k l = (/= 15) . f4 i j k l {-# INLINE notQuadrupleOrdered #-}++notQuintupleOrdered ::  Int -> Int -> Int -> Int -> Int -> Array Int Int -> Bool+notQuintupleOrdered i j k l m = (/= 31) . f5 i j k l m+{-# INLINE notQuintupleOrdered #-}  notSeveralAOrdered :: Int -> Array Int Int -> Array Int Int -> Bool notSeveralAOrdered !i0 !arr1 = not . isSeveralAOrdered i0 arr1
Phladiprelio/ConstraintsEncoded.hs view
@@ -42,6 +42,7 @@   , isN   , isD   , isI+  , isU   -- * Algebraic general conversion   , validOrdStr   , generalConversion@@ -52,7 +53,7 @@ import GHC.List import GHC.Num ((+),(-),abs) import Text.Show (show, Show(..))-import Text.Read (readMaybe, read)+import Text.Read (readMaybe) import Data.Maybe import Data.List (nub, words, groupBy) import GHC.Arr@@ -77,6 +78,7 @@   | N a d  -- ^ Represents the set of permutations with the moved fixed positions of some elements (at least one).   | D a a a a  -- ^ Pepresents the set of permutations with the specified order and distance between the two elements.   | I a a a a -- ^ Pepresents the set of permutations with the specified distance between the two elements.+  | U a a a a a a -- ^ Represents the set of permutations with the preserved order of the 5 elements   deriving (Eq, Ord, Show)  validOrdStr0 @@ -84,41 +86,41 @@   -> Int -- ^ Number of seen so far \'(\' parentheses   -> Int -- ^ Number of seen so far \')\' parentheses   -> Bool-validOrdStr0 xs@('E':ys) n m = validOrdStr0 ys n m-validOrdStr0 xs@(' ':y:t:ys) n m-  | y `elem` "ABDFHIMNPQRTVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n m+validOrdStr0 ('E':ys) n m = validOrdStr0 ys n m+validOrdStr0 (' ':y:t:ys) n m+  | y `elem` "ABDFHIMNPQRTUVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n m   | y `elem` "-(E" = validOrdStr0 (y:t:ys) n m   | otherwise = False  -validOrdStr0 xs@('(':y:t:ys) n m-  | y `elem` "ABDFHIMNPQRTVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) (n + 1) m+validOrdStr0 ('(':y:t:ys) n m+  | y `elem` "ABDFHIMNPQRTUVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) (n + 1) m   | y `elem` "-(E" = validOrdStr0 (y:t:ys) (n + 1) m   | otherwise = False  -validOrdStr0 xs@(')':y:t:ys) n m-  | y `elem` "ABDFHIMNPQRTVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n (m + 1)+validOrdStr0 (')':y:t:ys) n m+  | y `elem` "ABDFHIMNPQRTUVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n (m + 1)   | y `elem` "-()E" = validOrdStr0 (y:t:ys) n (m + 1)   | otherwise = False  -validOrdStr0 xs@('-':y:t:ys) n m-  | y `elem` "ABDFHIMNPQRTVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n m +validOrdStr0 ('-':y:t:ys) n m+  | y `elem` "ABDFHIMNPQRTUVW" && isDigit t = validOrdStr0 (dropWhile isDigit ys) n m    | y `elem` "-)" || isDigit y = False   | otherwise = validOrdStr0 (y:t:ys) n m -validOrdStr0 xs@(x:y:t:ys) n m -  | x `elem` "ABDFHIMNPQRTVW" && isDigit y = validOrdStr0 (dropWhile isDigit (t:ys)) n m -  | x `elem` "ABDFHIMNPQRTVW" = False+validOrdStr0 (x:y:t:ys) n m +  | x `elem` "ABDFHIMNPQRTUVW" && isDigit y = validOrdStr0 (dropWhile isDigit (t:ys)) n m +  | x `elem` "ABDFHIMNPQRTUVW" = False   | otherwise = validOrdStr0 (y:t:ys) n (m + 1) -validOrdStr0 xs@(x:')':ys) n m +validOrdStr0 (x:')':ys) n m    | isDigit x = validOrdStr0 ys n (m + 1)   | x == ')' = validOrdStr0 ys n (m + 2)    | otherwise = False-validOrdStr0 xs@(x:y:ys) n m -  | x `elem` "(ABDFHIMNQRTVW" = False-  | y `elem` " -(ABDFHIMNPQRTVW" = False+validOrdStr0 (x:y:_) n m +  | x `elem` "(ABDFHIMNQRTUVW" = False+  | y `elem` " -(ABDFHIMNPQRTUVW" = False   | x == 'P' && not (isDigit y) = False   | x == ')' && y /= 'E' = False   | x == 'P' && n == m = True   | x == ')' && y == 'E' = n == (m + 1)   | (x `elem` "E -") && y == 'E' = n == m    | otherwise = False-validOrdStr0 xs@(x:ys) n m +validOrdStr0 (x:_) n m    | isDigit x || (x `elem` ")E") = if x == ')' then n == (m + 1) else n == m    | otherwise = False validOrdStr0 _ n m  = n == m@@ -139,9 +141,9 @@   -> Array Int Int    -> [String]    -> String -- ^ The result is a 'String' that Haskell can evaluate to 'Bool' (some logical expression).-convertToBools n arr xss@("-":yss) = "not " `mappend` (convertToBools n arr yss)-convertToBools n arr xss@(" ":yss) = " || " `mappend` (convertToBools n arr yss)-convertToBools n arr xss@(xs:yss@(ys:tss))+convertToBools n arr ("-":yss) = "not " `mappend` (convertToBools n arr yss)+convertToBools n arr (" ":yss) = " || " `mappend` (convertToBools n arr yss)+convertToBools n arr (xs:yss@(ys:_))   | xs `elem` ["True","False"] = xs `mappend` (case ys of                                                   " "   -> " "                                                  _     -> " && ") `mappend` convertToBools n arr yss @@ -150,13 +152,13 @@                       `mappend` (case ys of                                     " "   -> " "                                    _     -> " && ") `mappend` convertToBools n arr yss -convertToBools n arr xss@(xs:yss) +convertToBools n arr (xs:_)    | xs `elem` ["True","False"] = xs   | otherwise = (show . isConstraint1 True arr . fromMaybe E . readMaybeECG n $ xs) -convertToBools n arr _ = []+convertToBools _ _ _ = []  splitNoParenAtDisjunction :: [String] -> [[String]]-splitNoParenAtDisjunction xss@(xs:yss) +splitNoParenAtDisjunction xss@(_:_)    | null tss = []   | otherwise = tss : splitNoParenAtDisjunction wss        where (tss,uss) = break (== "||") xss@@ -164,17 +166,17 @@ splitNoParenAtDisjunction _ = []  noParenString0 :: [String] -> Bool -noParenString0 xss@(xs:ys:ts:yss) +noParenString0 (xs:ys:ts:yss)    | xs == "not" =        case ys of          "True" -> False -        "False" -> noParenString0 yss +        _ -> noParenString0 yss    | otherwise =        case xs of         "True" -> noParenString0 (ts:yss)-        "False" -> False -noParenString0 xss@("not":ys:yss) = if ys == "True" then False else True -noParenString0 xss@(xs:yss) +        _ -> False +noParenString0 ("not":ys:_) = if ys == "True" then False else True +noParenString0 (xs:_)    | xs == "True" = True    | otherwise = False  noParenString0 _ = True@@ -197,7 +199,7 @@                                                                then (drop 1 xs:tss, 1, rss)                                                                else case n of                                                                        0 -> (tss, 0, xs:rss)-                                                                      1 -> (xs:tss, 1, rss)) ([], 0, []) $ yss) `mappend` kss+                                                                      _ -> (xs:tss, 1, rss)) ([], 0, []) $ yss) `mappend` kss   where (yss,wss) = break (any (== ')')) xss         kss = case wss of                 ")":vss -> vss @@ -234,7 +236,7 @@        _   -> f n h ts  | otherwise = Nothing          where f n c ts -                 | c `elem` "DFHIMQRQTVW" = +                 | c `elem` "DFHIMQRQTUVW" =                         let ys0 =catMaybes . map (\t -> readMaybe [t]::Maybe Int) $ ts                            ys = nub ys0                            (jjs, ps) = splitAtEndG 1 ys0@@ -243,8 +245,9 @@                                                                         [y,z] = map (\rr ->  if rr == 0 then 9 else rr - 1) qs in if length qs /= 2 || ps == [0] || ps > [n] then Nothing else Just ((if c == 'D' then D else I) n y z (head ps))                              | length ys /= g c = Nothing                              | c == 'Q' = let [y,z,u,w] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just (Q n y z u w)-                             | c `elem` "FVW" = let [y,z] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just ((case c of {'F' -> F; 'V'-> V; ~ww -> W}) n y z)-                             | c `elem` "HMT" = let [y,z,u] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just ((case c of {'T' -> T; 'H' -> H; 'M' -> M; ~rr -> R}) n y z u)+                             | c == 'U' = let [y,z,t,u,w] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just (U n y z t u w)+                             | c `elem` "FVW" = let [y,z] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just ((case c of {'F' -> F; 'V'-> V; _ -> W}) n y z)+                             | c `elem` "HMT" = let [y,z,u] = map (\rr -> if rr  == 0 then 9 else rr - 1) ys in Just ((case c of {'T' -> T; 'H' -> H; 'M' -> M; _ -> R}) n y z u)                              | otherwise = Nothing in res                  | c `elem` "AB" = let y = readMaybe (take 1 ts)::Maybe Int in                                      if isJust y then@@ -254,10 +257,10 @@                                                  [] -> Nothing                                                  ~x2 -> Just ((if c == 'A' then SA else SB) n (if y0 == 0 then 9 else y0 - 1) (listArray (0,length x2 - 1) x2))                                      else Nothing -                 | c == 'P' = if null ts then Just E else Just . P n . listArray (0,length ts - 1) . map (\r -> case (fromJust (readMaybe [r]::Maybe Int)) of {0 -> 9; n -> n-1}) $ ts-                 | c == 'N' = if tl == 0 then Just E else Just . N n . listArray (0, tl - 1) . map ((\[s,w] -> (w, s)) . map (\r -> case (fromJust (readMaybe [r]::Maybe Int)) of {0 -> 9; n -> n-1})) $ h3+                 | c == 'P' = if null ts then Just E else Just . P n . listArray (0,length ts - 1) . map (\r -> case (fromJust (readMaybe [r]::Maybe Int)) of {0 -> 9; q -> q-1}) $ ts+                 | c == 'N' = if tl == 0 then Just E else Just . N n . listArray (0, tl - 1) . map ((\[s,w] -> (w, s)) . map (\r -> case (fromJust (readMaybe [r]::Maybe Int)) of {0 -> 9; q -> q-1})) $ h3                  | otherwise = Nothing-                        where h1 bs@(b:d:ds) = [b,d]:h1 ds+                        where h1 (b:d:ds) = [b,d]:h1 ds                               h1 _ = []                                h2 = h1 ts                               qqs = map head h2@@ -269,6 +272,7 @@                g c                   | c `elem` "FVW" = 2                  | c == 'Q' = 4+                 | c == 'U' = 5                  | otherwise = 3  @@ -292,6 +296,7 @@ decodeConstraint1 (N _ v) = fixedPointsG v decodeConstraint1 (D _ i j d) = filterSignDistanceIJ i j (abs d) decodeConstraint1 (I _ i j d) = filterUnsignDistanceIJ i j (abs d)+decodeConstraint1 (U _ i j k l m) = unsafeQuintuples i j k l m   -- | Must be applied to the correct array of permutation indeces. Otherwise, it gives runtime error (exception). All the integers inside the@@ -308,7 +313,7 @@ decodeLConstraints _ = id  isConstraint1 :: Bool -> Array Int Int -> EncodedCnstrs -> Bool-isConstraint1 bool arr E = bool+isConstraint1 bool _ E = bool isConstraint1 True arr (F _ i j) = unsafeOrderIJ i j arr  isConstraint1 True arr (T _ i j k) = isTripleOrdered i j k arr  isConstraint1 True arr (Q _ i j k l) = isQuadrupleOrdered i j k l arr @@ -323,6 +328,7 @@ isConstraint1 True arr (N _ arr2) = isFixedPointTup arr2 arr  isConstraint1 True arr (D _ i j d) = unsafeSignDistanceIJ i j (abs d) arr  isConstraint1 True arr (I _ i j d) = unsafeUnsignDistanceIJ i j (abs d) arr +isConstraint1 True arr (U _ i j k l m) = isQuintupleOrdered i j k l m arr  isConstraint1 False arr (F _ i j) = unsafeOrderIJ j i arr  isConstraint1 False arr (T _ i j k) = notTripleOrdered i j k arr  isConstraint1 False arr (Q _ i j k l) = notQuadrupleOrdered i j k l arr @@ -337,6 +343,7 @@ isConstraint1 False arr (N _ arr2) = notFixedPointTup arr2 arr  isConstraint1 False arr (D _ i j d) = unsafeSignDistanceIJ j i (abs d) arr  isConstraint1 False arr (I _ i j d) = not . unsafeUnsignDistanceIJ i j (abs d) $ arr +isConstraint1 False arr (U _ i j k l m) = notQuintupleOrdered i j k l m arr   isE :: EncodedCnstrs -> Bool isE E = True@@ -398,7 +405,11 @@ isI (I _ _ _ _) = True isI _ = False +isU :: EncodedCnstrs -> Bool+isU (U _ _ _ _ _ _) = True+isU _ = False + {-| Works only with the correctly defined argument though it is not checked. Use with this caution. -} getIEl :: EncodedCnstrs -> Int@@ -417,6 +428,7 @@ getIEl (N _ arr) = fst . unsafeAt arr $ 0  getIEl (D _ i _ _) = i getIEl (I _ i _ _) = i+getIEl (U _ i _ _ _ _) = i  {-| Works only with the correctly defined arguments though it is not checked. Use with this caution. -}@@ -433,7 +445,8 @@ 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-setIEl i (N n arr) = N n arr+setIEl _ (N n arr) = N n arr setIEl i (D n _ j k) = D n i j k setIEl i (I n _ j k) = I n i j k+setIEl i (U n _ j k l m) = U n i j k l m 
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.7.2.0+version:             0.7.3.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