word8set 0.1 → 0.1.1
raw patch · 4 files changed
+110/−1 lines, 4 filesdep +tastydep +tasty-quickcheckdep +word8setdep ~QuickCheckdep ~basedep ~latticesPVP ok
version bump matches the API change (PVP)
Dependencies added: tasty, tasty-quickcheck, word8set
Dependency ranges changed: QuickCheck, base, lattices
API changes (from Hackage documentation)
+ Data.Word8Set: instance Algebra.Heyting.Heyting Data.Word8Set.Word8Set
+ Data.Word8Set: instance Algebra.PartialOrd.PartialOrd Data.Word8Set.Word8Set
+ Data.Word8Set: instance Data.String.IsString Data.Word8Set.Word8Set
+ Data.Word8Set: symmetricDifference :: Word8Set -> Word8Set -> Word8Set
Files
- CHANGELOG.md +7/−0
- src/Data/Word8Set.hs +38/−0
- tests/word8set-tests.hs +46/−0
- word8set.cabal +19/−1
CHANGELOG.md view
@@ -1,3 +1,10 @@+## 0.1.1++- Add `IsString Word8Set` instance, with `fromString = fromASCII`.+- Add `PartialOrd Word8Set` instance.+- Add `Heyting Word8Set` instance.+- Add `symmetricDifference`.+ ## 0.1 * First version. Released on an unsuspecting world.
src/Data/Word8Set.hs view
@@ -58,6 +58,7 @@ union, unions, difference,+ symmetricDifference, (\\), intersection, complement,@@ -106,11 +107,14 @@ otherwise, return, showParen, showString, snd, ($), (&&), (+), (-), (.), (/=), (<=), (>)) import Algebra.Lattice (BoundedJoinSemiLattice (..), BoundedMeetSemiLattice (..), Lattice (..))+import Algebra.Heyting (Heyting (..))+import Algebra.PartialOrd (PartialOrd (..)) import Control.DeepSeq (NFData (..)) import Data.Bits ((.&.), (.|.)) import Data.Char (chr, ord) import Data.Monoid (Monoid (..)) import Data.Semigroup (Semigroup (..))+import Data.String (IsString (..)) import Data.WideWord.Word256 (Word256 (..)) import Data.Word (Word8) import Test.QuickCheck (Arbitrary (..), CoArbitrary (..), Function (..), functionMap)@@ -191,11 +195,31 @@ instance BoundedMeetSemiLattice Word8Set where top = full +-- |+--+-- @since 0.1.1+instance Heyting Word8Set where+ a ==> b = neg a \/ b + neg = complement+ a <=> b = complement (symmetricDifference a b)++-- | @'leq' = 'isSubsetOf'@+--+-- @since 0.1.1+instance PartialOrd Word8Set where+ leq = isSubsetOf+ instance GHC.Exts.IsList Word8Set where type Item Word8Set = Key fromList = fromList toList = toList +-- | @'fromString' = 'fromASCII'@+--+-- @since 0.1.1+instance IsString Word8Set where+ fromString = fromASCII+ ------------------------------------------------------------------------------- -- Construction -------------------------------------------------------------------------------@@ -494,6 +518,20 @@ -- | Difference between two sets. difference :: Word8Set -> Word8Set -> Word8Set difference xs ys = intersection xs (complement ys)++-- | Symmetric difference between two sets+--+-- @+-- 'symmetricDifference' xs ys = 'difference' ('union' xs ys) ('intersection' xs ys)+-- @+--+-- >>> symmetricDifference (range 10 20) (range 15 25)+-- fromList [10,11,12,13,14,21,22,23,24,25]+--+-- @since 0.1.1+--+symmetricDifference :: Word8Set -> Word8Set -> Word8Set+symmetricDifference (W8S xs) (W8S ys) = W8S (Bits.xor xs ys) -- | See 'difference'. (\\) :: Word8Set -> Word8Set -> Word8Set
+ tests/word8set-tests.hs view
@@ -0,0 +1,46 @@+module Main (main) where++import Algebra.Heyting (Heyting (..))+import Algebra.Lattice (bottom, top, (/\))+import Data.Word8Set (Word8Set)+import Test.QuickCheck (Property, (===))+import Test.Tasty (defaultMain, testGroup)+import Test.Tasty.QuickCheck (testProperty)++main :: IO ()+main = defaultMain $ testGroup "word8set"+ [ testProperty "heyting1" heyting1+ , testProperty "heyting2" heyting2+ , testProperty "heyting3" heyting3+ , testProperty "heyting4" heyting4+ , testProperty "heytingNeg" heytingNeg+ , testProperty "heytingEquiv" heytingEquiv+ ]++-------------------------------------------------------------------------------+-- Heyting+--+-- x ==> x ≡ top+-- x /\ (x ==> y) ≡ x /\ y+-- y /\ (x ==> y) ≡ y+-- x ==> (y /\ z) ≡ (x ==> y) /\ (x ==> z)+--+-------------------------------------------------------------------------------++heyting1 :: Word8Set -> Property+heyting1 x = (x ==> x) === top++heyting2 :: Word8Set -> Word8Set -> Property+heyting2 x y = (x /\ (x ==> y)) === x /\ y++heyting3 :: Word8Set -> Word8Set -> Property+heyting3 x y = (y /\ (x ==> y)) === y++heyting4 :: Word8Set -> Word8Set -> Word8Set -> Property+heyting4 x y z = (x ==> (y /\ z)) === (x ==> y) /\ (x ==> z)++heytingNeg :: Word8Set -> Property+heytingNeg x = neg x === x ==> bottom++heytingEquiv :: Word8Set -> Word8Set -> Property+heytingEquiv x y = x <=> y === (x ==> y) /\ (y ==> x)
word8set.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: word8set-version: 0.1+version: 0.1.1 synopsis: Word8 set description: Set of Word8 numbers. Backed up by Word256. category: Data@@ -44,3 +44,21 @@ , lattices ^>=2.2 , QuickCheck ^>=2.14.2 , wide-word ^>=0.1.5.0++test-suite word8set-tests+ default-language: Haskell2010+ type: exitcode-stdio-1.0+ hs-source-dirs: tests+ main-is: word8set-tests.hs++ -- library dependencies+ build-depends:+ , base+ , lattices+ , QuickCheck+ , word8set++ -- test dependencies+ build-depends:+ , tasty ^>=1.4.3+ , tasty-quickcheck ^>=0.10.2