bitwise-enum 1.0.0.3 → 1.0.1.0
raw patch · 5 files changed
+40/−19 lines, 5 filesdep ~aesondep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, vector
API changes (from Hackage documentation)
+ Data.Enum.Set: toRaw :: forall a. AsEnumSet a => EnumSet a -> EnumSetRep a
+ Data.Enum.Set.Base: toRaw :: forall w a. EnumSet w a -> w
Files
- CHANGES.md +3/−0
- Data/Enum/Set.hs +7/−0
- Data/Enum/Set/Base.hs +8/−1
- bitwise-enum.cabal +17/−17
- tests/set-properties.hs +5/−1
+ CHANGES.md view
@@ -0,0 +1,3 @@+## [1.0.1.0]++* Add `EnumSet.toRaw`.
Data/Enum/Set.hs view
@@ -124,6 +124,7 @@ -- * Conversion , toList , fromRaw + , toRaw ) where import Prelude hiding (all, any, filter, foldl, foldl1, foldMap, foldr, foldr1, map, maximum, minimum, null, traverse) @@ -381,3 +382,9 @@ fromRaw :: ∀ a. AsEnumSet a => EnumSetRep a -> EnumSet a fromRaw = E.fromRaw {-# INLINE fromRaw #-} + +-- | /O(1)/. Convert an @EnumSet@ into its representation. +-- Intended for use with foreign types. +toRaw :: ∀ a. AsEnumSet a => EnumSet a -> EnumSetRep a +toRaw = E.toRaw +{-# INLINE toRaw #-}
Data/Enum/Set/Base.hs view
@@ -119,6 +119,7 @@ -- * Conversion , toList , fromRaw + , toRaw ) where import qualified GHC.Exts @@ -617,11 +618,17 @@ fromRaw = EnumSet {-# INLINE fromRaw #-} +-- | /O(1)/. Convert an @EnumSet@ into its representation. +-- Intended for use with foreign types. +toRaw :: ∀ w a. EnumSet w a -> w +toRaw (EnumSet x) = x +{-# INLINE toRaw #-} + {-------------------------------------------------------------------- Utility functions --------------------------------------------------------------------} --- | Least significant bit. +-- | Least significant bit. lsb :: ∀ w. (FiniteBits w, Num w) => w -> Int lsb = countTrailingZeros {-# INLINE lsb #-}
bitwise-enum.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: ee84edf13441f046fa34c363bde7afdf23d3bef8aabe9a215ae4f296f4844976+-- hash: 5fdbdf5677b7ae0a0c640e45ae5ba0dc5db8950240db416cd566fb5f90d288d2 name: bitwise-enum-version: 1.0.0.3+version: 1.0.1.0 synopsis: Bitwise operations on bounded enumerations description: Bitwise operations on bounded enumerations. .@@ -38,12 +38,12 @@ ./ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -ferror-spans -funbox-small-strict-fields -O2 build-depends:- aeson >=0.11 && <1.5.6- , array >=0.5.1 && <0.5.5+ aeson >=0.11 && <1.6+ , array >=0.5.1 && <0.6 , base >=4.5 && <5- , deepseq >=1.1 && <1.4.5- , mono-traversable >=1.0.12 && <1.0.16- , vector >=0.11 && <0.12.2+ , deepseq >=1.1 && <1.5+ , mono-traversable >=1.0.12 && <1.1+ , vector >=0.11 && <0.13 default-language: Haskell2010 test-suite enumset-test-suite@@ -56,15 +56,15 @@ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -ferror-spans -funbox-small-strict-fields build-depends: QuickCheck >=2.13.2- , aeson >=0.11 && <1.5.6- , array >=0.5.1 && <0.5.5+ , aeson >=0.11 && <1.6+ , array >=0.5.1 && <0.6 , base , bitwise-enum- , deepseq >=1.1 && <1.4.5- , mono-traversable >=1.0.12 && <1.0.16+ , deepseq >=1.1 && <1.5+ , mono-traversable >=1.0.12 && <1.1 , test-framework >=0.8.2.0 , test-framework-quickcheck2 >=0.3.0.5- , vector >=0.11 && <0.12.2+ , vector >=0.11 && <0.13 default-language: Haskell2010 benchmark enumset-benchmarks@@ -76,13 +76,13 @@ benchmarks ghc-options: -Wall -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -ferror-spans -funbox-small-strict-fields -rtsopts -threaded -with-rtsopts=-N -O2 build-depends:- aeson >=0.11 && <1.5.6- , array >=0.5.1 && <0.5.5+ aeson >=0.11 && <1.6+ , array >=0.5.1 && <0.6 , base , bitwise-enum- , deepseq >=1.1 && <1.4.5+ , deepseq >=1.1 && <1.5 , gauge >=0.2.5- , mono-traversable >=1.0.12 && <1.0.16- , vector >=0.11 && <0.12.2+ , mono-traversable >=1.0.12 && <1.1+ , vector >=0.11 && <0.13 , wide-word >=0.1.0.9 default-language: Haskell2010
tests/set-properties.hs view
@@ -62,6 +62,7 @@ , testProperty "maxView" prop_maxView -- Conversion , testProperty "toList" prop_toList + , testProperty "fromRaw/toRaw" prop_raw , testProperty "Read/Show" prop_readShow ] @@ -252,6 +253,9 @@ prop_toList :: [Key] -> Bool prop_toList xs = sort (nub xs) == E.toList (E.fromFoldable xs :: ES) +prop_raw :: ES -> Bool +prop_raw s = s == E.fromRaw (E.toRaw s) + prop_readShow :: ES -> Bool prop_readShow s = s == read (show s) @@ -261,7 +265,7 @@ -> (f -> Maybe Key -> ES -> Maybe Key) -> (f -> Maybe Key -> [Key] -> Maybe Key) -> Fun Key Bool -> ES -> Bool -originHelper reorder fSet fList p s = +originHelper reorder fSet fList p s = fSet f Nothing s == fList f Nothing (E.toList s) where f = reorder \acc x -> acc <|> [x | apply p x]