mmsyn2-array 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+22/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- CaseBi/Arr.hs +15/−10
- mmsyn2-array.cabal +3/−2
CHANGELOG.md view
@@ -11,3 +11,7 @@ ## 0.1.1.0 -- 2020-12-18 * First version revised B. Fixed issue with the first and last elements of the array that were not taken into account.++## 0.1.2.0 -- 2021-03-28++* First version revised C. Some code optimization improvements. Changed the inner implementation and imported modules.
CaseBi/Arr.hs view
@@ -1,10 +1,12 @@ {-# OPTIONS_HADDOCK show-extensions #-}+{-# OPTIONS_GHC -funbox-strict-fields #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MagicHash #-} -- | Module : CaseBi.Arr--- Copyright : (c) OleksandrZhabenko 2020+-- Copyright : (c) OleksandrZhabenko 2020-2021 -- License : MIT -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com@@ -30,6 +32,7 @@ import qualified Data.List as L (sortBy) import GHC.Arr+import GHC.Exts import Data.Ord (comparing) {- | The function that can be used instead of the 'case ... of' function@@ -55,22 +58,24 @@ -> b -- ^ The default value that is used if no first element in the array tuples equals to the compared value. -> a -- ^ The compared value, well, the @main@ function argument, to which it is applied. -> b -- ^ The resulting branch value.-getBFst'' (# i, k #) (# j, m #) arr def x+getBFst'' (# (I# i#), k #) (# (I# j#), m #) arr def x | if x < fst k then True else x > fst m = def- | otherwise = gBF3 (# i, k #) (# j, m #) arr def x+ | otherwise = gBF3 (# i#, k #) (# j#, m #) arr def x {-# INLINE getBFst'' #-} --- | The meaning of the arguments is the same as for 'getBFst'''. Is used internally in it.-gBF3 :: Ord a => (# Int, (a, b) #) -> (# Int, (a, b) #) -> Array i (a, b) -> b -> a -> b-gBF3 (# i, k #) (# j, m #) arr def x- | j - i > 1 = let !n = (i + j) `quot` 2 in let !p = unsafeAt arr n in+-- | The meaning of the arguments is the same as for 'getBFst'''. Is used internally in it. +gBF3 :: Ord a => (# Int#, (a, b) #) -> (# Int#, (a, b) #) -> Array i (a, b) -> b -> a -> b+gBF3 (# !i#, k #) (# !j#, m #) arr def x+ | isTrue# ((j# -# i#) ># 1# ) = case compare x (fst p) of- GT -> gBF3 (# n, p #) (# j, m #) arr def x- EQ -> snd p- _ -> gBF3 (# i, k #) (# n, p #) arr def x+ GT -> gBF3 (# n#, p #) (# j#, m #) arr def x+ LT -> gBF3 (# i#, k #) (# n#, p #) arr def x+ _ -> snd p | x == fst m = snd m | x == fst k = snd k | otherwise = def+ where !n# = (i# +# j#) `quotInt#` 2#+ !p = unsafeAt arr (I# n#) {-# INLINABLE gBF3 #-} -- | A generally written without extending variant of the 'getBFst'''.
mmsyn2-array.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn2-array-version: 0.1.1.0+version: 0.1.2.0 synopsis: A library with less dependencies that can be used for multiple Ord a => a -> b transformations. description: A library that can be used as a @case ... of@ constuction analogue for the multiple @Ord a => a -> b@ transformations and data representation. Uses "GHC.Arr" internally. If you use the module in GHCi, then, please, run the interpreter with the flag -fobject-code. homepage: https://hackage.haskell.org/package/mmsyn2-array@@ -19,7 +19,8 @@ library exposed-modules: CaseBi.Arr -- other-modules:- other-extensions: UnboxedTuples, BangPatterns, FlexibleContexts+ other-extensions: UnboxedTuples, BangPatterns, FlexibleContexts, MagicHash+ ghc-options: -funbox-strict-fields build-depends: base >=4.7 && <4.15 -- hs-source-dirs: default-language: Haskell2010