{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE KindSignatures #-}
module Data.EnumSet where
import Prelude (Eq, Ord, Enum, Functor (..), (.), ($), (>))
import Control.DeepSeq
import Data.IntSet
import Data.Typeable
import Data.Data
import Data.Semigroup
import Data.Monoid
import Text.ParserCombinators.ReadPrec
import Text.Read
import Text.Show
import Data.EnumMapSetWrapper
newtype EnumSet k = EnumSet { unEnumSet :: IntSet } deriving
(Eq, Ord, Semigroup, Monoid, Typeable, Data, NFData)
w '(\\)
w 'null
w 'size
w 'member
w 'notMember
w 'lookupLT
w 'lookupGT
w 'lookupLE
w 'lookupGE
w 'isSubsetOf
w 'isProperSubsetOf
w 'empty
w 'singleton
w 'insert
w 'delete
w 'union
w 'unions
w 'difference
w 'intersection
w 'filter
w 'partition
w 'split
w 'splitMember
w' 'map
w 'foldr
w 'foldl
w 'foldr'
w 'foldl'
w 'findMin
w 'findMax
w 'deleteMin
w 'deleteMax
w 'deleteFindMin
w 'deleteFindMax
w 'maxView
w 'minView
w 'elems
w 'toList
w 'fromList
w 'toAscList
w 'toDescList
w 'fromAscList
w 'fromDistinctAscList
w 'showTree
w 'showTreeWith
instance (Enum k, Show k) => Show (EnumSet k) where
showsPrec p s = showParen (p > 10) $
showString "fromList " . shows (Data.EnumSet.toList s)
instance (Enum k, Read k) => Read (EnumSet k) where
readPrec = parens . prec 10 $ do
Ident "fromList" <- lexP
fmap Data.EnumSet.fromList readPrec