lazyset- Set and Map from lazy/infinite lists.

Copyright(c) Carlos Freund 2016
Safe HaskellSafe




A Set that can be created from lazy, ordered, infinite lists.



data LazySet a Source #


LazySet [Set a] 


Eq a => Eq (LazySet a) Source # 


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

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

Show a => Show (LazySet a) Source # 


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

show :: LazySet a -> String #

showList :: [LazySet a] -> ShowS #


member :: Ord a => a -> LazySet a -> Bool Source #

Checks if the value is a member of the LazySet. Performance: O(m)=log m Where m is the position of the element beeing searched for. This only applies after the element has been fetched from the underlying list.

lookup :: Ord a => a -> LazySet a -> Maybe a Source #

Searches for a value in a Set. If it can not be found returns Nothing otherwhise Returns 'Just a' if it can find it. The returned value will be the one from the set, not the one that was passed.

null :: LazySet a -> Bool Source #

Returns true if the LazSet is empty.

size :: Ord a => LazySet a -> Int Source #

Returns the size of the set. Do not use this on infinite Sets.


spanAntitone :: Ord a => (a -> Bool) -> LazySet a -> (LazySet a, LazySet a) Source #

Splits the LazySet into two parts. The first containing all consecutive elements of the Set where the predicate applies. The second contains the (infinite) rest.

union :: Ord a => LazySet a -> LazySet a -> LazySet a Source #

Union of two LazySets.


empty :: Ord a => LazySet a Source #

Create an empty LazySet.

fromAscList :: Ord a => [a] -> LazySet a Source #

Builds a LazySet from an ascending ordered list. If the list is not ordered an error is thrown.

growFromAscList Source #


:: Ord a 
=> Float

The factor by which the subtrees grow. Must be >= 1.0. A growth of 1.0 makes the LazySet behave like a List. The higher it is set, the more it behaves like a Set. The downside of a higher growth-factor is that bigger batches are extracted from the source-list at once.

-> [a]

An ascending List

-> LazySet a 

Like fromAscList but with a custom growth-factor.

fromList :: Ord a => [a] -> LazySet a Source #

Alias for fromAscList.

fromDescList :: Ord a => [a] -> LazySet (Down a) Source #

Create a LazSet from a descending list.

build Source #


:: Ord a 
=> Int


-> Float


-> [a]

Ascending source-list

-> [Set a] 

Kind of internal.


toList :: Ord a => LazySet a -> [a] Source #

List with all elements in order.