{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Set.Lifted
( Set
, empty
, singleton
, null
, member
, size
, difference
, (\\)
, intersection
, subset
, toArray
, LI.toList
, LI.fromList
, LI.foldr
, LI.foldl'
, LI.foldr'
, foldMap'
, foldMap
, traverse_
, itraverse_
) where
import Prelude hiding (foldr,foldMap,null)
import Data.Semigroup (Semigroup)
import Data.Set.Lifted.Internal (Set(..))
import Data.Primitive (Array)
import qualified Data.Set.Internal as I
import qualified Data.Set.Lifted.Internal as LI
difference :: Ord a => Set a -> Set a -> Set a
difference (Set x) (Set y) = Set (I.difference x y)
intersection :: Ord a => Set a -> Set a -> Set a
intersection (Set x) (Set y) = Set (I.intersection x y)
subset :: Ord a => Set a -> Set a -> Bool
subset (Set x) (Set y) = I.subset x y
empty :: Set a
empty = Set I.empty
(\\) :: Ord a => Set a -> Set a -> Set a
(\\) (Set x) (Set y) = Set (I.difference x y)
null :: Set a -> Bool
null (Set s) = I.null s
member :: Ord a => a -> Set a -> Bool
member a (Set s) = I.member a s
singleton :: a -> Set a
singleton = Set . I.singleton
size :: Set a -> Int
size (Set s) = I.size s
foldMap' :: Monoid m
=> (a -> m)
-> Set a
-> m
foldMap' f (Set arr) = I.foldMap' f arr
foldMap :: Monoid m
=> (a -> m)
-> Set a
-> m
foldMap f (Set arr) = I.foldMap f arr
toArray :: Set a -> Array a
toArray (Set s) = I.toArray s
traverse_ :: Applicative m
=> (a -> m b)
-> Set a
-> m ()
traverse_ f (Set arr) = I.traverse_ f arr
itraverse_ :: Applicative m
=> (Int -> a -> m b)
-> Set a
-> m ()
itraverse_ f (Set arr) = I.itraverse_ f arr
{-# INLINEABLE itraverse_ #-}