Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype MultisetHash = MultisetHash Int
- nullMH :: MultisetHash -> Bool
- emptyMH :: MultisetHash
- singletonMH :: (a -> MultisetHash) -> a -> MultisetHash
- insertMH :: (a -> MultisetHash) -> a -> MultisetHash -> MultisetHash
- deleteMH :: (a -> MultisetHash) -> a -> MultisetHash -> MultisetHash
- unionMH :: MultisetHash -> MultisetHash -> MultisetHash
- differenceMH :: MultisetHash -> MultisetHash -> MultisetHash
- fromListMH :: (a -> MultisetHash) -> [a] -> MultisetHash
Documentation
newtype MultisetHash Source #
Instances
nullMH :: MultisetHash -> Bool Source #
singletonMH :: (a -> MultisetHash) -> a -> MultisetHash Source #
insertMH :: (a -> MultisetHash) -> a -> MultisetHash -> MultisetHash Source #
>>>
hs = randoms (mkStdGen 123)
>>>
fromListMH (hs!!) [1,2]
MultisetHash (-6020088438187520526)>>>
fromListMH (hs!!) [1,1,2]
MultisetHash (-9031158793612401624)>>>
insertMH (hs!!) 1 (fromListMH (hs!!) [1,2])
MultisetHash (-9031158793612401624)>>>
hash x = hs !! mod x 10
prop> \x xs -> fromListMH hash (x:xs) == insertMH hash x (fromListMH hash xs) +++ OK, passed 100 tests.
deleteMH :: (a -> MultisetHash) -> a -> MultisetHash -> MultisetHash Source #
>>>
hs = randoms (mkStdGen 123)
>>>
fromListMH (hs!!) [1,2]
MultisetHash (-6020088438187520526)>>>
fromListMH (hs!!) [1,1,2]
MultisetHash (-9031158793612401624)>>>
deleteMH (hs!!) 1 (fromListMH (hs!!) [1,1,2])
MultisetHash (-6020088438187520526)
unionMH :: MultisetHash -> MultisetHash -> MultisetHash Source #
>>>
hs = randoms (mkStdGen 123)
>>>
unionMH (fromListMH (hs!!) [1,1,2]) (fromListMH (hs!!) [1,3])
MultisetHash 6625208473658164035>>>
fromListMH (hs!!) $ [1,1,2] <> [1,3]
MultisetHash 6625208473658164035
differenceMH :: MultisetHash -> MultisetHash -> MultisetHash Source #
>>>
hs = randoms (mkStdGen 123)
>>>
differenceMH (fromListMH (hs!!) [1,1,2]) (fromListMH (hs!!) [1,2])
MultisetHash (-3011070355424881098)>>>
fromListMH (hs!!) [1]
MultisetHash (-3011070355424881098)>>>
differenceMH (fromListMH (hs!!) [1,1,2]) (fromListMH (hs!!) [1,3])
MultisetHash (-6240781987173415667)
fromListMH :: (a -> MultisetHash) -> [a] -> MultisetHash Source #
>>>
hs = randoms (mkStdGen 123)
>>>
fromListMH (hs !!) [1,1,1,2,2,3]
MultisetHash 3616190390895524607>>>
fromListMH (hs !!) [1,2,1,3,1,2]
MultisetHash 3616190390895524607>>>
map (fromListMH (hs!!)) [[1],[1,1],[1,1,1]]
[MultisetHash (-3011070355424881098),MultisetHash (-6022140710849762196),MultisetHash (-9033211066274643294)]>>>
hash x = hs !! mod x 10
prop> \xs ys -> fromListMH hash (xs ++ ys) == fromListMH hash xs <> fromListMH hash ys +++ OK, passed 100 tests.