{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wall #-}
module Data.Set.Unboxed
( S.Set
, empty
, singleton
, doubleton
, tripleton
, null
, member
, size
, difference
, (\\)
, intersection
, subset
, enumFromTo
, S.toList
, S.fromList
, toArray
, foldr
, foldMap
, foldl'
, foldr'
, foldMap'
, traverse_
, itraverse_
, mapMonotonic
) where
import Prelude hiding (foldr,foldMap,null,enumFromTo)
import Data.Hashable (Hashable)
import Data.Primitive.PrimArray (PrimArray)
import Data.Primitive.Types (Prim)
import Data.Primitive.UnliftedArray (PrimUnlifted(..))
import Data.Semigroup (Semigroup)
import Data.Set.Unboxed.Internal (Set(..))
import qualified Data.Foldable as F
import qualified Data.Hashable as H
import qualified Data.Semigroup as SG
import qualified GHC.Exts as E
import qualified Data.Set.Internal as I
import qualified Data.Set.Unboxed.Internal as S
empty :: Set a
empty = Set I.empty
difference :: (Ord a, Prim a) => Set a -> Set a -> Set a
difference (Set x) (Set y) = Set (I.difference x y)
(\\) :: (Ord a, Prim a) => Set a -> Set a -> Set a
(\\) (Set x) (Set y) = Set (I.difference x y)
intersection :: (Ord a, Prim a) => Set a -> Set a -> Set a
intersection (Set x) (Set y) = Set (I.intersection x y)
subset :: (Ord a, Prim a) => Set a -> Set a -> Bool
subset (Set x) (Set y) = I.subset x y
enumFromTo :: (Enum a, Ord a, Num a, Prim a)
=> a
-> a
-> Set a
enumFromTo lo hi = Set (I.enumFromTo lo hi)
member :: (Prim a, Ord a) => a -> Set a -> Bool
member a (Set s) = I.member a s
null :: Set a -> Bool
null (Set s) = I.null s
singleton :: Prim a => a -> Set a
singleton = Set . I.singleton
doubleton :: (Prim a, Ord a) => a -> a -> Set a
doubleton a b = Set (I.doubleton a b)
tripleton :: (Prim a, Ord a) => a -> a -> a -> Set a
tripleton a b c = Set (I.tripleton a b c)
size :: Prim a => Set a -> Int
size (Set s) = I.size s
foldr :: Prim a
=> (a -> b -> b)
-> b
-> Set a
-> b
foldr f b0 (Set s) = I.foldr f b0 s
foldl' :: Prim a
=> (b -> a -> b)
-> b
-> Set a
-> b
foldl' f b0 (Set s) = I.foldl' f b0 s
foldr' :: Prim a
=> (a -> b -> b)
-> b
-> Set a
-> b
foldr' f b0 (Set s) = I.foldr' f b0 s
foldMap' :: (Monoid m, Prim a)
=> (a -> m)
-> Set a
-> m
foldMap' f (Set arr) = I.foldMap' f arr
foldMap :: (Monoid m, Prim a)
=> (a -> m)
-> Set a
-> m
foldMap f (Set arr) = I.foldMap f arr
toArray :: Set a -> PrimArray a
toArray (Set s) = I.toArray s
traverse_ :: (Applicative m, Prim a)
=> (a -> m b)
-> Set a
-> m ()
traverse_ f (Set arr) = I.traverse_ f arr
itraverse_ :: (Applicative m, Prim a)
=> (Int -> a -> m b)
-> Set a
-> m ()
itraverse_ f (Set arr) = I.itraverse_ f arr
{-# INLINEABLE itraverse_ #-}
mapMonotonic :: (Prim a, Prim b)
=> (a -> b)
-> Set a
-> Set b
mapMonotonic f (Set arr) = Set (I.map f arr)
{-# INLINEABLE mapMonotonic #-}