{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnicodeSyntax #-}
module Data.Enum.Set
( AsEnumSet(..)
, EnumSet
, empty
, singleton
, fromFoldable
, insert
, delete
, member
, notMember
, null
, size
, isSubsetOf
, union
, difference
, (\\)
, symmetricDifference
, intersection
, filter
, partition
, map
, foldl, foldl', foldr, foldr'
, foldl1, foldl1', foldr1, foldr1'
, foldMap
, traverse
, any
, all
, minimum
, maximum
, deleteMin
, deleteMax
, minView
, maxView
, toList
, fromRaw
, toRaw
) where
import Prelude hiding (all, any, filter, foldl, foldl1, foldMap, foldr, foldr1, map, maximum, minimum, null, traverse)
import Data.Bits
import qualified Data.Enum.Set.Base as E
class (Enum a, FiniteBits (EnumSetRep a), Num (EnumSetRep a)) => AsEnumSet a where
type EnumSetRep a
type EnumSetRep a = Word
type EnumSet a = E.EnumSet (EnumSetRep a) a
empty :: ∀ a. AsEnumSet a => EnumSet a
empty :: EnumSet a
empty = EnumSet a
forall k w (a :: k). Bits w => EnumSet w a
E.empty
{-# INLINE empty #-}
singleton :: ∀ a. AsEnumSet a => a -> EnumSet a
singleton :: a -> EnumSet a
singleton = a -> EnumSet a
forall w a. (Bits w, Enum a) => a -> EnumSet w a
E.singleton
{-# INLINE singleton #-}
fromFoldable :: ∀ f a. (Foldable f, AsEnumSet a) => f a -> EnumSet a
fromFoldable :: f a -> EnumSet a
fromFoldable = f a -> EnumSet a
forall (f :: * -> *) w a.
(Foldable f, Bits w, Enum a) =>
f a -> EnumSet w a
E.fromFoldable
{-# INLINE fromFoldable #-}
insert :: ∀ a. AsEnumSet a => a -> EnumSet a -> EnumSet a
insert :: a -> EnumSet a -> EnumSet a
insert = a -> EnumSet a -> EnumSet a
forall w a. (Bits w, Enum a) => a -> EnumSet w a -> EnumSet w a
E.insert
{-# INLINE insert #-}
delete :: ∀ a. AsEnumSet a => a -> EnumSet a -> EnumSet a
delete :: a -> EnumSet a -> EnumSet a
delete = a -> EnumSet a -> EnumSet a
forall w a. (Bits w, Enum a) => a -> EnumSet w a -> EnumSet w a
E.delete
{-# INLINE delete #-}
member :: ∀ a. AsEnumSet a => a -> EnumSet a -> Bool
member :: a -> EnumSet a -> Bool
member = a -> EnumSet a -> Bool
forall w a. (Bits w, Enum a) => a -> EnumSet w a -> Bool
E.member
{-# INLINE member #-}
notMember :: ∀ a. AsEnumSet a => a -> EnumSet a -> Bool
notMember :: a -> EnumSet a -> Bool
notMember = a -> EnumSet a -> Bool
forall w a. (Bits w, Enum a) => a -> EnumSet w a -> Bool
E.notMember
{-# INLINE notMember #-}
null :: ∀ a. AsEnumSet a => EnumSet a -> Bool
null :: EnumSet a -> Bool
null = EnumSet a -> Bool
forall k w (a :: k). Bits w => EnumSet w a -> Bool
E.null
{-# INLINE null #-}
size :: ∀ a. AsEnumSet a => EnumSet a -> Int
size :: EnumSet a -> Int
size = EnumSet a -> Int
forall k w (a :: k). (Bits w, Num w) => EnumSet w a -> Int
E.size
{-# INLINE size #-}
isSubsetOf :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> Bool
isSubsetOf :: EnumSet a -> EnumSet a -> Bool
isSubsetOf = EnumSet a -> EnumSet a -> Bool
forall k w (a :: k). Bits w => EnumSet w a -> EnumSet w a -> Bool
E.isSubsetOf
{-# INLINE isSubsetOf #-}
union :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> EnumSet a
union :: EnumSet a -> EnumSet a -> EnumSet a
union = EnumSet a -> EnumSet a -> EnumSet a
forall k w (a :: k).
Bits w =>
EnumSet w a -> EnumSet w a -> EnumSet w a
E.union
{-# INLINE union #-}
difference :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> EnumSet a
difference :: EnumSet a -> EnumSet a -> EnumSet a
difference = EnumSet a -> EnumSet a -> EnumSet a
forall k w (a :: k).
Bits w =>
EnumSet w a -> EnumSet w a -> EnumSet w a
E.difference
{-# INLINE difference #-}
(\\) :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> EnumSet a
\\ :: EnumSet a -> EnumSet a -> EnumSet a
(\\) = EnumSet a -> EnumSet a -> EnumSet a
forall k w (a :: k).
Bits w =>
EnumSet w a -> EnumSet w a -> EnumSet w a
E.difference
infixl 9 \\
{-# INLINE (\\) #-}
symmetricDifference :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> EnumSet a
symmetricDifference :: EnumSet a -> EnumSet a -> EnumSet a
symmetricDifference = EnumSet a -> EnumSet a -> EnumSet a
forall k w (a :: k).
Bits w =>
EnumSet w a -> EnumSet w a -> EnumSet w a
E.symmetricDifference
{-# INLINE symmetricDifference #-}
intersection :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a -> EnumSet a
intersection :: EnumSet a -> EnumSet a -> EnumSet a
intersection = EnumSet a -> EnumSet a -> EnumSet a
forall k w (a :: k).
Bits w =>
EnumSet w a -> EnumSet w a -> EnumSet w a
E.intersection
{-# INLINE intersection #-}
filter :: ∀ a. AsEnumSet a => (a -> Bool) -> EnumSet a -> EnumSet a
filter :: (a -> Bool) -> EnumSet a -> EnumSet a
filter = (a -> Bool) -> EnumSet a -> EnumSet a
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> Bool) -> EnumSet w a -> EnumSet w a
E.filter
{-# INLINE filter #-}
partition :: ∀ a. AsEnumSet a
=> (a -> Bool) -> EnumSet a -> (EnumSet a, EnumSet a)
partition :: (a -> Bool) -> EnumSet a -> (EnumSet a, EnumSet a)
partition = (a -> Bool) -> EnumSet a -> (EnumSet a, EnumSet a)
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> Bool) -> EnumSet w a -> (EnumSet w a, EnumSet w a)
E.partition
{-# INLINE partition #-}
map :: ∀ a b. (AsEnumSet a, AsEnumSet b) => (a -> b) -> EnumSet a -> EnumSet b
map :: (a -> b) -> EnumSet a -> EnumSet b
map = (a -> b) -> EnumSet a -> EnumSet b
forall v w a b.
(FiniteBits v, FiniteBits w, Num v, Num w, Enum a, Enum b) =>
(a -> b) -> EnumSet v a -> EnumSet w b
E.map'
foldl :: ∀ a b. AsEnumSet a => (b -> a -> b) -> b -> EnumSet a -> b
foldl :: (b -> a -> b) -> b -> EnumSet a -> b
foldl = (b -> a -> b) -> b -> EnumSet a -> b
forall w a b.
(FiniteBits w, Num w, Enum a) =>
(b -> a -> b) -> b -> EnumSet w a -> b
E.foldl
{-# INLINE foldl #-}
foldl' :: ∀ a b. AsEnumSet a => (b -> a -> b) -> b -> EnumSet a -> b
foldl' :: (b -> a -> b) -> b -> EnumSet a -> b
foldl' = (b -> a -> b) -> b -> EnumSet a -> b
forall w a b.
(FiniteBits w, Num w, Enum a) =>
(b -> a -> b) -> b -> EnumSet w a -> b
E.foldl'
{-# INLINE foldl' #-}
foldr :: ∀ a b. AsEnumSet a => (a -> b -> b) -> b -> EnumSet a -> b
foldr :: (a -> b -> b) -> b -> EnumSet a -> b
foldr = (a -> b -> b) -> b -> EnumSet a -> b
forall w a b.
(FiniteBits w, Num w, Enum a) =>
(a -> b -> b) -> b -> EnumSet w a -> b
E.foldr
{-# INLINE foldr #-}
foldr' :: ∀ a b. AsEnumSet a => (a -> b -> b) -> b -> EnumSet a -> b
foldr' :: (a -> b -> b) -> b -> EnumSet a -> b
foldr' = (a -> b -> b) -> b -> EnumSet a -> b
forall w a b.
(FiniteBits w, Num w, Enum a) =>
(a -> b -> b) -> b -> EnumSet w a -> b
E.foldr'
{-# INLINE foldr' #-}
foldl1 :: ∀ a. AsEnumSet a => (a -> a -> a) -> EnumSet a -> a
foldl1 :: (a -> a -> a) -> EnumSet a -> a
foldl1 = (a -> a -> a) -> EnumSet a -> a
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> a -> a) -> EnumSet w a -> a
E.foldl1
{-# INLINE foldl1 #-}
foldl1' :: ∀ a. AsEnumSet a => (a -> a -> a) -> EnumSet a -> a
foldl1' :: (a -> a -> a) -> EnumSet a -> a
foldl1' = (a -> a -> a) -> EnumSet a -> a
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> a -> a) -> EnumSet w a -> a
E.foldl1'
{-# INLINE foldl1' #-}
foldr1 :: ∀ a. AsEnumSet a => (a -> a -> a) -> EnumSet a -> a
foldr1 :: (a -> a -> a) -> EnumSet a -> a
foldr1 = (a -> a -> a) -> EnumSet a -> a
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> a -> a) -> EnumSet w a -> a
E.foldr1
{-# INLINE foldr1 #-}
foldr1' :: ∀ a. AsEnumSet a => (a -> a -> a) -> EnumSet a -> a
foldr1' :: (a -> a -> a) -> EnumSet a -> a
foldr1' = (a -> a -> a) -> EnumSet a -> a
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> a -> a) -> EnumSet w a -> a
E.foldr1'
{-# INLINE foldr1' #-}
foldMap :: ∀ m a. (Monoid m, AsEnumSet a) => (a -> m) -> EnumSet a -> m
foldMap :: (a -> m) -> EnumSet a -> m
foldMap = (a -> m) -> EnumSet a -> m
forall m w a.
(Monoid m, FiniteBits w, Num w, Enum a) =>
(a -> m) -> EnumSet w a -> m
E.foldMap
{-# INLINE foldMap #-}
traverse :: ∀ f a. (Applicative f, AsEnumSet a)
=> (a -> f a) -> EnumSet a -> f (EnumSet a)
traverse :: (a -> f a) -> EnumSet a -> f (EnumSet a)
traverse = (a -> f a) -> EnumSet a -> f (EnumSet a)
forall (f :: * -> *) w a.
(Applicative f, FiniteBits w, Num w, Enum a) =>
(a -> f a) -> EnumSet w a -> f (EnumSet w a)
E.traverse
{-# INLINE traverse #-}
all :: ∀ a. AsEnumSet a => (a -> Bool) -> EnumSet a -> Bool
all :: (a -> Bool) -> EnumSet a -> Bool
all = (a -> Bool) -> EnumSet a -> Bool
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> Bool) -> EnumSet w a -> Bool
E.all
{-# INLINE all #-}
any :: ∀ a. AsEnumSet a => (a -> Bool) -> EnumSet a -> Bool
any :: (a -> Bool) -> EnumSet a -> Bool
any = (a -> Bool) -> EnumSet a -> Bool
forall w a.
(FiniteBits w, Num w, Enum a) =>
(a -> Bool) -> EnumSet w a -> Bool
E.any
{-# INLINE any #-}
minimum :: ∀ a. AsEnumSet a => EnumSet a -> a
minimum :: EnumSet a -> a
minimum = EnumSet a -> a
forall w a. (FiniteBits w, Num w, Enum a) => EnumSet w a -> a
E.minimum
{-# INLINE minimum #-}
maximum :: ∀ a. AsEnumSet a => EnumSet a -> a
maximum :: EnumSet a -> a
maximum = EnumSet a -> a
forall w a. (FiniteBits w, Num w, Enum a) => EnumSet w a -> a
E.maximum
{-# INLINE maximum #-}
deleteMin :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a
deleteMin :: EnumSet a -> EnumSet a
deleteMin = EnumSet a -> EnumSet a
forall k w (a :: k).
(FiniteBits w, Num w) =>
EnumSet w a -> EnumSet w a
E.deleteMin
{-# INLINE deleteMin #-}
deleteMax :: ∀ a. AsEnumSet a => EnumSet a -> EnumSet a
deleteMax :: EnumSet a -> EnumSet a
deleteMax = EnumSet a -> EnumSet a
forall k w (a :: k).
(FiniteBits w, Num w) =>
EnumSet w a -> EnumSet w a
E.deleteMax
{-# INLINE deleteMax #-}
minView :: ∀ a. AsEnumSet a => EnumSet a -> Maybe (a, EnumSet a)
minView :: EnumSet a -> Maybe (a, EnumSet a)
minView = EnumSet a -> Maybe (a, EnumSet a)
forall w a.
(FiniteBits w, Num w, Enum a) =>
EnumSet w a -> Maybe (a, EnumSet w a)
E.minView
{-# INLINE minView #-}
maxView :: ∀ a. AsEnumSet a => EnumSet a -> Maybe (a, EnumSet a)
maxView :: EnumSet a -> Maybe (a, EnumSet a)
maxView = EnumSet a -> Maybe (a, EnumSet a)
forall w a.
(FiniteBits w, Num w, Enum a) =>
EnumSet w a -> Maybe (a, EnumSet w a)
E.maxView
{-# INLINE maxView #-}
toList :: ∀ a. AsEnumSet a => EnumSet a -> [a]
toList :: EnumSet a -> [a]
toList = EnumSet a -> [a]
forall w a. (FiniteBits w, Num w, Enum a) => EnumSet w a -> [a]
E.toList
{-# INLINE toList #-}
fromRaw :: ∀ a. AsEnumSet a => EnumSetRep a -> EnumSet a
fromRaw :: EnumSetRep a -> EnumSet a
fromRaw = EnumSetRep a -> EnumSet a
forall k w (a :: k). w -> EnumSet w a
E.fromRaw
{-# INLINE fromRaw #-}
toRaw :: ∀ a. AsEnumSet a => EnumSet a -> EnumSetRep a
toRaw :: EnumSet a -> EnumSetRep a
toRaw = EnumSet a -> EnumSetRep a
forall k w (a :: k). EnumSet w a -> w
E.toRaw
{-# INLINE toRaw #-}