{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -O2 #-}
module Data.Set.Unlifted
( S.Set
, empty
, singleton
, null
, member
, size
, difference
, intersection
, enumFromTo
, toArray
, S.toList
, S.fromList
, foldr
, foldMap
, foldl'
, foldr'
, foldMap'
, traverse_
, itraverse_
) where
import Prelude hiding (foldr,foldMap,null,enumFromTo)
import Data.Primitive.UnliftedArray (UnliftedArray, PrimUnlifted(..))
import Data.Semigroup (Semigroup)
import Data.Set.Unlifted.Internal (Set(..))
import qualified Data.Set.Internal as I
import qualified Data.Set.Unlifted.Internal as S
member :: (PrimUnlifted a, Ord a) => a -> Set a -> Bool
member a (Set s) = I.member a s
empty :: Set a
empty = Set I.empty
null :: Set a -> Bool
null (Set s) = I.null s
singleton :: PrimUnlifted a => a -> Set a
singleton = Set . I.singleton
size :: PrimUnlifted a => Set a -> Int
size (Set s) = I.size s
difference :: (PrimUnlifted a, Ord a) => Set a -> Set a -> Set a
difference (Set x) (Set y) = Set (I.difference x y)
intersection :: (Ord a, PrimUnlifted a) => Set a -> Set a -> Set a
intersection (Set x) (Set y) = Set (I.intersection x y)
enumFromTo :: (Enum a, Ord a, Num a, PrimUnlifted a)
=> a
-> a
-> Set a
enumFromTo lo hi = Set (I.enumFromTo lo hi)
toArray :: Set a -> UnliftedArray a
toArray (Set s) = I.toArray s
foldr :: PrimUnlifted a
=> (a -> b -> b)
-> b
-> Set a
-> b
foldr f b0 (Set s) = I.foldr f b0 s
foldMap :: (PrimUnlifted a, Monoid m)
=> (a -> m)
-> Set a
-> m
foldMap f (Set s) = I.foldMap f s
foldl' :: PrimUnlifted a
=> (b -> a -> b)
-> b
-> Set a
-> b
foldl' f b0 (Set s) = I.foldl' f b0 s
foldr' :: PrimUnlifted a
=> (a -> b -> b)
-> b
-> Set a
-> b
foldr' f b0 (Set s) = I.foldr' f b0 s
foldMap' :: (PrimUnlifted a, Monoid m)
=> (a -> m)
-> Set a
-> m
foldMap' f (Set arr) = I.foldMap' f arr
traverse_ :: (Applicative m, PrimUnlifted a)
=> (a -> m b)
-> Set a
-> m ()
traverse_ f (Set arr) = I.traverse_ f arr
itraverse_ :: (Applicative m, PrimUnlifted a)
=> (Int -> a -> m b)
-> Set a
-> m ()
itraverse_ f (Set arr) = I.itraverse_ f arr