constrained-monads-0.2.0.0: Typeclasses and instances for monads with constraints.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Constrained.IntSet

Description

This module creates an IntSet type with a phantom type variable, allowing it to conform to Functor, Foldable, etc. Other than that, it's a duplication of the Data.IntSet module.

Synopsis

Documentation

data IntSet a Source #

This type is a wrapper around IntSet, with a phantom type variable which must always be Int. This allows it to conform to Functor, Foldable, Applicative, Monad, etc.

Instances

Foldable IntSet Source # 

Methods

fold :: Monoid m => IntSet m -> m #

foldMap :: Monoid m => (a -> m) -> IntSet a -> m #

foldr :: (a -> b -> b) -> b -> IntSet a -> b #

foldr' :: (a -> b -> b) -> b -> IntSet a -> b #

foldl :: (b -> a -> b) -> b -> IntSet a -> b #

foldl' :: (b -> a -> b) -> b -> IntSet a -> b #

foldr1 :: (a -> a -> a) -> IntSet a -> a #

foldl1 :: (a -> a -> a) -> IntSet a -> a #

toList :: IntSet a -> [a] #

null :: IntSet a -> Bool #

length :: IntSet a -> Int #

elem :: Eq a => a -> IntSet a -> Bool #

maximum :: Ord a => IntSet a -> a #

minimum :: Ord a => IntSet a -> a #

sum :: Num a => IntSet a -> a #

product :: Num a => IntSet a -> a #

Eq1 IntSet Source # 

Methods

liftEq :: (a -> b -> Bool) -> IntSet a -> IntSet b -> Bool #

Ord1 IntSet Source # 

Methods

liftCompare :: (a -> b -> Ordering) -> IntSet a -> IntSet b -> Ordering #

Show1 IntSet Source # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> IntSet a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [IntSet a] -> ShowS #

Alternative IntSet Source # 
Monad IntSet Source # 

Methods

(>>=) :: Suitable IntSet b => IntSet a -> (a -> IntSet b) -> IntSet b Source #

Applicative IntSet Source # 

Methods

pure :: Suitable IntSet a => a -> IntSet a Source #

(<*>) :: Suitable IntSet b => IntSet (a -> b) -> IntSet a -> IntSet b Source #

(*>) :: Suitable IntSet b => IntSet a -> IntSet b -> IntSet b Source #

(<*) :: Suitable IntSet a => IntSet a -> IntSet b -> IntSet a Source #

liftA :: Suitable IntSet a => FunType xs a -> AppVect IntSet xs -> IntSet a Source #

liftA2 :: Suitable IntSet c => (a -> b -> c) -> IntSet a -> IntSet b -> IntSet c Source #

liftA3 :: Suitable IntSet d => (a -> b -> c -> d) -> IntSet a -> IntSet b -> IntSet c -> IntSet d Source #

Functor IntSet Source # 

Associated Types

type Suitable (IntSet :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable IntSet b => (a -> b) -> IntSet a -> IntSet b Source #

(<$) :: Suitable IntSet a => a -> IntSet b -> IntSet a Source #

(~) * a Int => IsList (IntSet a) Source # 

Associated Types

type Item (IntSet a) :: * #

Methods

fromList :: [Item (IntSet a)] -> IntSet a #

fromListN :: Int -> [Item (IntSet a)] -> IntSet a #

toList :: IntSet a -> [Item (IntSet a)] #

Eq a => Eq (IntSet a) Source # 

Methods

(==) :: IntSet a -> IntSet a -> Bool #

(/=) :: IntSet a -> IntSet a -> Bool #

Ord a => Ord (IntSet a) Source # 

Methods

compare :: IntSet a -> IntSet a -> Ordering #

(<) :: IntSet a -> IntSet a -> Bool #

(<=) :: IntSet a -> IntSet a -> Bool #

(>) :: IntSet a -> IntSet a -> Bool #

(>=) :: IntSet a -> IntSet a -> Bool #

max :: IntSet a -> IntSet a -> IntSet a #

min :: IntSet a -> IntSet a -> IntSet a #

(~) * a Int => Read (IntSet a) Source # 
Show a => Show (IntSet a) Source # 

Methods

showsPrec :: Int -> IntSet a -> ShowS #

show :: IntSet a -> String #

showList :: [IntSet a] -> ShowS #

Semigroup (IntSet a) Source # 

Methods

(<>) :: IntSet a -> IntSet a -> IntSet a #

sconcat :: NonEmpty (IntSet a) -> IntSet a #

stimes :: Integral b => b -> IntSet a -> IntSet a #

(~) * a Int => Monoid (IntSet a) Source # 

Methods

mempty :: IntSet a #

mappend :: IntSet a -> IntSet a -> IntSet a #

mconcat :: [IntSet a] -> IntSet a #

type Suitable IntSet a Source # 
type Suitable IntSet a = (~) * a Int
type Item (IntSet a) Source # 
type Item (IntSet a) = a

(\\) :: IntSet a -> IntSet a -> IntSet a infixl 9 Source #

O(n+m). See difference.

lookupLT :: a -> IntSet a -> Maybe a Source #

O(log n). Find largest element smaller than the given one.

lookupLT 3 (fromList [3, 5]) == Nothing
lookupLT 5 (fromList [3, 5]) == Just 3

lookupLE :: a -> IntSet a -> Maybe a Source #

O(log n). Find largest element smaller or equal to the given one.

lookupLE 2 (fromList [3, 5]) == Nothing
lookupLE 4 (fromList [3, 5]) == Just 3
lookupLE 5 (fromList [3, 5]) == Just 5

lookupGT :: a -> IntSet a -> Maybe a Source #

O(log n). Find smallest element greater than the given one.

lookupGT 4 (fromList [3, 5]) == Just 5
lookupGT 5 (fromList [3, 5]) == Nothing

lookupGE :: a -> IntSet a -> Maybe a Source #

O(log n). Find smallest element greater or equal to the given one.

lookupGE 3 (fromList [3, 5]) == Just 3
lookupGE 4 (fromList [3, 5]) == Just 5
lookupGE 6 (fromList [3, 5]) == Nothing

insert :: a -> IntSet a -> IntSet a Source #

O(min(n,W)). Add a value to the set. There is no left- or right bias for IntSets.

delete :: a -> IntSet a -> IntSet a Source #

O(min(n,W)). Delete a value in the set. Returns the original set when the value was not present.

difference :: IntSet a -> IntSet a -> IntSet a Source #

O(n+m). Difference between two sets.

intersection :: IntSet a -> IntSet a -> IntSet a Source #

O(n+m). The intersection of two sets.

filter :: (a -> Bool) -> IntSet a -> IntSet a Source #

O(n). Filter all elements that satisfy some predicate.

partition :: (a -> Bool) -> IntSet a -> (IntSet a, IntSet a) Source #

O(n). partition the set according to some predicate.

split :: a -> IntSet a -> (IntSet a, IntSet a) Source #

O(min(n,W)). The expression (split x set) is a pair (set1,set2) where set1 comprises the elements of set less than x and set2 comprises the elements of set greater than x.

split 3 (fromList [1..5]) == (fromList [1,2], fromList [4,5])

maxView :: IntSet a -> Maybe (a, IntSet a) Source #

O(min(n,W)). Retrieves the maximal key of the set, and the set stripped of that element, or Nothing if passed an empty set.

minView :: IntSet a -> Maybe (a, IntSet a) Source #

O(min(n,W)). Retrieves the minimal key of the set, and the set stripped of that element, or Nothing if passed an empty set.