IdrisDoc: Data.SortedBag

# Data.SortedBag

OnMapsT : Nat -> Type -> Type

  A type for converting a function from an operation over SortedMaps to an
  operation over SortedBags

data SortedBag : Type -> Type
  BagWrapper : SortedMap k PosNat -> SortedBag k
UpdateBag : Type -> Type

  The type of `insert` and the common core of most functions that update
  the contests of a Bag.

alterCounts : (Nat -> Nat) -> UpdateBag k

  Apply a function `(Nat -> Nat)` to a given argument

contains : k -> SortedBag k -> Bool

  Is a count non-zero?

count : k -> SortedBag k -> Nat

  Count the number of occurances

countMap : k -> SortedMap k PosNat -> Nat

  Perform a count on the underlying `SortedMap`

delete : UpdateBag k

  Delete all ocurances

delete1 : UpdateBag k

  delete 1 item (equivalent to `deleteN 1`)

deleteN : Nat -> UpdateBag k

  delete a given number of items

empty : Ord k => SortedBag k

  An empty bag.

fromList : Ord k => List k -> SortedBag k

  Convert a list to a Sorted Bag

insert : UpdateBag k

  insert a single item.

insertN : Nat -> UpdateBag k

  insert a given number of items

null : SortedBag k -> Bool

  O(1). Are there any items? The proof in PosNat ensures that there are no
  zero-counted items.

onMap : OnMapsT (fromInteger 1) k

  Special case for n=1 for `onMaps`

onMaps : OnMapsT n k

  Apply an n-ary function over the wrapped `SortedMap`.

singleton : Ord k => k -> SortedBag k

  A single item (more efficient than `insert x empty`)

toList : SortedBag k -> List k

  Convert a Sorted Bag to a List, keeping it sorted.

union : EndoChain (fromInteger 2) (SortedBag k)

  Merge two bags

unwrapBag : SortedBag k -> SortedMap k PosNat

  Remove the `BagWrapper` from a bag (the required proof from `PosNat` makes
  this safe)

wrappedBagIso : Iso (SortedMap k PosNat) (SortedBag k)

  An `Isomorphism` between a wrapped and unwrapped bag