packages feed

phonetic-languages-constraints-array 0.7.3.0 → 0.8.0.0

raw patch · 6 files changed

+72/−12 lines, 6 filesdep +monoid-insertleftdep −subGPVP ok

version bump matches the API change (PVP)

Dependencies added: monoid-insertleft

Dependencies removed: subG

API changes (from Hackage documentation)

- Phladiprelio.ConstraintsEncoded: instance (GHC.Classes.Eq a, GHC.Classes.Eq b, GHC.Classes.Eq d) => GHC.Classes.Eq (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
- Phladiprelio.ConstraintsEncoded: instance (GHC.Classes.Ord a, GHC.Classes.Ord b, GHC.Classes.Ord d) => GHC.Classes.Ord (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
- Phladiprelio.ConstraintsEncoded: instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show d) => GHC.Show.Show (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
+ Phladiprelio.ConstraintsEncoded: instance (GHC.Classes.Eq b, GHC.Classes.Eq d, GHC.Classes.Eq a) => GHC.Classes.Eq (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
+ Phladiprelio.ConstraintsEncoded: instance (GHC.Classes.Ord b, GHC.Classes.Ord d, GHC.Classes.Ord a) => GHC.Classes.Ord (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
+ Phladiprelio.ConstraintsEncoded: instance (GHC.Show.Show b, GHC.Show.Show d, GHC.Show.Show a) => GHC.Show.Show (Phladiprelio.ConstraintsEncoded.EncodedContraints a b d)
- Phladiprelio.ConstraintsEncoded: type EncodedCnstrs = EncodedContraints Int (Array Int Int) (Array Int (Int, Int))
+ Phladiprelio.ConstraintsEncoded: type EncodedCnstrs = EncodedContraints Int Array Int Int Array Int (Int, Int)

Files

CHANGELOG.md view
@@ -86,3 +86,7 @@ * 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).  +## 0.8.0.0 -- 2024-01-27++* Eighth version. Updated the dependencies and switched to monoid-insertleft instead of subG. Added specializing and inlining for some functions to improve performance. Some documentation improvements.+
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020-2023 Oleksandr Zhabenko+Copyright (c) 2020-2024 Oleksandr Zhabenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
Phladiprelio/Constraints.hs view
@@ -2,7 +2,7 @@  -- | -- Module      :  Pladiprelio.Constraints--- Copyright   :  (c) OleksandrZhabenko 2020-2023+-- Copyright   :  (c) OleksandrZhabenko 2020-2024 -- License     :  MIT -- Stability   :  Experimental -- Maintainer  :  oleksandr.zhabenko@yahoo.com@@ -65,7 +65,7 @@  import GHC.Base hiding (foldr) import GHC.Num (Num, (-),(+))-import Data.SubG (InsertLeft(..),filterG)+import Data.InsertLeft (InsertLeft(..),filterG) import GHC.Arr import GHC.Int (Int8(..)) import Data.Bits ((.&.),testBit, shiftR, setBit, clearBit)@@ -79,6 +79,7 @@           | x == i = bitChange (testBit y 0) y 1           | otherwise = y {-# INLINE f2 #-}+{-# SPECIALIZE f2 :: Int -> Int -> Array Int Int -> Int8 #-}  f3 :: (Foldable t, Eq p) => p -> p -> p -> t p -> Int8 f3 i j k = foldr g (0::Int8) -- (== 7)@@ -89,6 +90,7 @@           | x == i = bitChange (clearBit y 2 == 3) y 2  -- (u && w, u, w)           | otherwise = y {-# INLINE f3 #-}+{-# SPECIALIZE f3 :: Int -> Int -> Int -> Array Int Int -> Int8 #-}  f4 :: (Foldable t, Eq p) => p -> p -> p -> p -> t p -> Int8 f4 i j k l = foldr g (0::Int8) -- (== 15)@@ -100,6 +102,7 @@           | x == i = bitChange (clearBit y 3 == 7) y 3            | otherwise = y {-# INLINE f4 #-}+{-# SPECIALIZE f4 :: Int -> Int -> Int -> Int -> Array Int Int -> Int8 #-}  f5 :: (Foldable t, Eq p) => p -> p -> p -> p -> p -> t p -> Int8 f5 i j k l m = foldr g (0::Int8) -- (== 31)@@ -112,7 +115,9 @@           | x == i = bitChange (clearBit y 4 == 15) y 4            | otherwise = y {-# INLINE f5 #-}---+{-# SPECIALIZE f5 :: Int -> Int -> Int -> Int -> Int -> Array Int Int -> Int8 #-}++ -- | @n@ must be in the range [0..7] though it is not checked here. bitChange   :: Bool @@ -122,10 +127,10 @@ 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 = (== 3) . f2 i j+{-# INLINE unsafeOrderIJ #-}  -- | 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@@ -137,12 +142,16 @@   -> Array Int Int   -> Bool unsafeSignDistanceIJ i j d = (\(_,_,r) -> if r > 100 then (100 - r) == d else r == d) . foldr helpG2 (j, i, -1)+{-# INLINE unsafeSignDistanceIJ #-} + 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)   | otherwise = (-1, u, n)+{-# INLINE helpG2 #-}+{-# SPECIALIZE helpG2 :: Int -> (Int, Int, Int) -> (Int, Int, Int)  #-}  -- | 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 unsigned @@ -155,36 +164,51 @@   -> Array Int Int    -> Bool unsafeUnsignDistanceIJ i j d = (\(_,_,r) -> r == d) . foldr helpG3 (j, i, -1)+{-# INLINE unsafeUnsignDistanceIJ #-}  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)   | otherwise = (-1, u, n)+{-# INLINE helpG3 #-}+{-# SPECIALIZE helpG3 :: Int -> (Int, Int, Int) -> (Int, Int, Int) #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that satisfy 'unsafeOrderIJ' as a predicate. filterOrderIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterOrderIJ i j = filterG (unsafeOrderIJ i j)+{-# INLINE filterOrderIJ #-}+{-# SPECIALIZE filterOrderIJ :: Int -> Int -> [Array Int Int] -> [Array Int Int] #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that satisfy 'unsafeSignDistanceIJ' as a predicate. filterSignDistanceIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterSignDistanceIJ i j d = filterG (unsafeSignDistanceIJ i j d)+{-# INLINE filterSignDistanceIJ #-}+{-# SPECIALIZE filterSignDistanceIJ :: Int -> Int -> Int -> [Array Int Int] -> [Array Int Int] #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that satisfy 'unsafeUnsignDistanceIJ' as a predicate. filterUnsignDistanceIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterUnsignDistanceIJ i j d = filterG (unsafeUnsignDistanceIJ i j d)+{-# INLINE filterUnsignDistanceIJ #-}+{-# SPECIALIZE filterUnsignDistanceIJ :: Int -> Int -> Int -> [Array Int Int] -> [Array Int Int] #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that pairwisely (1 and 2, 2 and 3) satisfy 'unsafeSignDistanceIJ' as a predicate. filterSignDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterSignDistanceIJK3 i j k d1 d2 = filterG (isSignDistIJK3 i j k d1 d2)+{-# INLINE filterSignDistanceIJK3 #-}+{-# SPECIALIZE filterSignDistanceIJK3 :: Int -> Int -> Int -> Int -> Int -> [Array Int Int] -> [Array Int Int]  #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that pairwisely (1 and 2, 2 and 3) satisfy 'unsafeUnsignDistanceIJ' as a predicate. filterUnsignDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterUnsignDistanceIJK3 i j k d1 d2 = filterG (isUnsignDistIJK3 i j k d1 d2)+{-# INLINE filterUnsignDistanceIJK3 #-}+{-# SPECIALIZE filterUnsignDistanceIJK3 :: Int -> Int -> Int -> Int -> Int -> [Array Int Int] -> [Array Int Int]  #-}  -- | Being given the data satisfying the constraints in the module header returns the elements that satisfy both 'unsafeSignDistanceIJ' with the 1st, 2nd and 4th arguments and 'unsafeUnsignDistanceIJ' with the 2nd, 3rd and 5th arguments as predicates. filterMixedDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) filterMixedDistanceIJK3 i j k d1 d2 = filterG (isMixedDistIJK3 i j k d1 d2)+{-# INLINE filterMixedDistanceIJK3 #-}+{-# SPECIALIZE filterMixedDistanceIJK3 :: Int -> Int -> Int -> Int -> Int -> [Array Int Int] -> [Array Int Int] #-}  -- | 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@@ -193,6 +217,8 @@ -- 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)+{-# INLINE unsafeTriples #-}+{-# SPECIALIZE unsafeTriples :: Int -> Int -> Int -> [Array Int Int] -> [Array Int Int]  #-}  -- | 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@@ -201,6 +227,8 @@ -- 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)+{-# INLINE unsafeQuadruples #-}+{-# SPECIALIZE unsafeQuadruples :: Int -> Int -> Int -> Int -> [Array Int Int] -> [Array Int Int]  #-}  -- | 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@@ -209,6 +237,8 @@ -- 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)+{-# INLINE unsafeQuintuples #-}+{-# SPECIALIZE unsafeQuintuples :: Int -> Int -> Int -> Int -> Int ->  [Array Int Int] -> [Array Int Int]  #-}  -- | 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.@@ -218,6 +248,8 @@ -- variants with the indices in the second argument all stand AFTER the element with the index equal to the first argument. unsafeSeveralA :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Array Int Int -> t (Array Int Int) -> t (Array Int Int) unsafeSeveralA !i0 arr = filterG (isSeveralAOrdered i0 arr)+{-# INLINE unsafeSeveralA #-}+{-# SPECIALIZE unsafeSeveralA :: Int -> Array Int Int -> [Array Int Int] -> [Array Int Int]  #-}  -- | 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.@@ -227,6 +259,8 @@ -- variants with the indices in the second argument all stand BEFORE the element with the index equal to the first argument. unsafeSeveralB :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Array Int Int -> t (Array Int Int) -> t (Array Int Int) unsafeSeveralB !i0 arr = filterG (isSeveralBOrdered i0 arr)+{-# INLINE unsafeSeveralB #-}+{-# SPECIALIZE unsafeSeveralB :: Int -> Array Int Int -> [Array Int Int] -> [Array Int Int]  #-}  -------------------------------------------------------------------------------- @@ -235,11 +269,15 @@ -- elements in the tuples respectively. fixedPointsG :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Array Int (Int,Int) -> t (Array Int Int) -> t (Array Int Int) fixedPointsG arr = filterG (isFixedPointTup arr)+{-# INLINE fixedPointsG #-}+{-# SPECIALIZE fixedPointsG :: Array Int (Int,Int) -> [Array Int Int] -> [Array Int Int]  #-}  -- | A simplified variant of the 'fixedPointsG' function where the specified elements stay on their place and that is -- why are 'fixed points' in the permutation specified. fixedPointsS :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Array Int Int -> t (Array Int Int) -> t (Array Int Int) fixedPointsS arr = filterG (isFixedPoint arr)+{-# INLINE fixedPointsS #-}+{-# SPECIALIZE fixedPointsS :: Array Int Int -> [Array Int Int] -> [Array Int Int]  #-}  ------------------------------------------ 
Phladiprelio/ConstraintsEncoded.hs view
@@ -1,8 +1,11 @@ {-# OPTIONS_HADDOCK show-extensions #-} +++ -- | -- Module      :  Phladiprelio.ConstraintsEncoded--- Copyright   :  (c) OleksandrZhabenko 2020-2023+-- Copyright   :  (c) OleksandrZhabenko 2020-2024 -- License     :  MIT -- Stability   :  Experimental -- Maintainer  :  oleksandr.zhabenko@yahoo.com@@ -59,7 +62,7 @@ import GHC.Arr import Data.Char (isDigit, isLetter) import Phladiprelio.Constraints-import Data.SubG (InsertLeft(..), splitAtEndG)+import Data.InsertLeft (InsertLeft(..), splitAtEndG) import Data.Tuple (fst)  data EncodedContraints a b d @@ -297,7 +300,7 @@ 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-+{-# SPECIALIZE decodeConstraint1 :: EncodedCnstrs -> [Array Int Int] -> [Array Int Int]  #-}  -- | 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-1] where @n@ corresponds to the maximum element in the permutation 'Array' 'Int' 'Int'.@@ -311,6 +314,7 @@         decodeLConstraints' (z:zs) = decodeLConstraints' zs . decodeConstraint1 z         decodeLConstraints' _ = id decodeLConstraints _ = id+{-# SPECIALIZE decodeLConstraints :: [EncodedCnstrs] -> [Array Int Int] -> [Array Int Int]  #-}  isConstraint1 :: Bool -> Array Int Int -> EncodedCnstrs -> Bool isConstraint1 bool _ E = bool
README.md view
@@ -1,9 +1,22 @@  Devotion  ======== -Since the 0.6.0.0 version, the author would like to devote this project to support the Foundation Gastrostars.-If you would like to share some financial support, please, contact the foundation+Since the 0.6.0.0 version, the author would like to devote this project to support the [Foundation Gastrostars](https://gastrostars.nl).++The foundation founder is [Emma Kok](https://www.emmakok.nl).++On the 06/01/2024 there is Sophie's Kok, a sister of Emma Kok, 19th Birthday (she is 18). Therefore, the version 0.5.0.0 is additionally devoted also to her. On the 22/01/2023 there is Day of Unity of Ukraine, and on the 23/01/2024 the Orthodox Christians have memory of St. Paulinus of Nola.++Besides, you can support Ukraine and Ukrainian people. ++All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees.++If you would like to share some financial support with Gastrostars, please, contact the mentioned foundation using the URL:  [Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte)++or ++[Donation Page](https://gastrostars.nl/doneren) 
phonetic-languages-constraints-array.cabal view
@@ -2,10 +2,11 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/  name:                phonetic-languages-constraints-array-version:             0.7.3.0+version:             0.8.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. Instead of vectors, uses arrays. homepage:            https://hackage.haskell.org/package/phonetic-languages-constraints-array+bug-reports:         https://github.com/Oleksandr-Zhabenko/phonetic-languages-constraints-array/issues license:             MIT license-file:        LICENSE author:              OleksandrZhabenko@@ -20,6 +21,6 @@   exposed-modules:     Phladiprelio.Constraints, Phladiprelio.ConstraintsEncoded   -- other-modules:   other-extensions:    BangPatterns, FlexibleInstances, FlexibleContexts, NoImplicitPrelude-  build-depends:       base >=4.13 && <5, subG == 0.6.1.0+  build-depends:       base >=4.13 && <5, monoid-insertleft == 0.1.0.1   -- hs-source-dirs:   default-language:    Haskell2010