shimmer-0.1.3.2: The Reflective Lambda Machine

Safe HaskellSafe
LanguageHaskell98

SMR.Data.Bag

Synopsis

Documentation

data Bag a Source #

An unordered collection of things. O(1) to add a single element, a list of elements, or union two bags.

Constructors

BagNil 
BagElem a 
BagList [a] 
BagUnion (Bag a) (Bag a) 

Instances

Show a => Show (Bag a) Source # 

Methods

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

show :: Bag a -> String #

showList :: [Bag a] -> ShowS #

nil :: Bag a Source #

O(1). Construct an empty bag.

singleton :: a -> Bag a Source #

O(1). Construct a bag containing a single element.

list :: [a] -> Bag a Source #

O(1). Construct a bag containing a list of elements.

union :: Bag a -> Bag a -> Bag a Source #

O(1). Union two bags.

toList :: Bag a -> [a] Source #

O(n). Convert a bag to a list. The elements come out in some deterministic but arbitrary order, no promises.

map :: (a -> b) -> Bag a -> Bag b Source #

Apply a function to all the elements in a bag.