HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerio-0.1.22.0Haskell2010

RIO.Set.Partial

Set partial functions. Import as:

import qualified RIO.Set.Partial as Set'
  • 7 values
  • Packagerio-0.1.22.0
  • Exports7
  • LanguageHaskell2010
  • LicenceMIT
  • SourcePartial.hs

Indexed

3 declarations
valuefindIndex :: Ord a => a -> Set a -> Int
#

O(\log n). Return the index of an element, which is its zero-based index in the sorted sequence of elements. The index is a number from 0 up to, but not including, the size of the set. Calls error when the element is not a member of the set.

findIndex 2 (fromList [5,3])    Error: element is not in the set
findIndex 3 (fromList [5,3]) == 0
findIndex 5 (fromList [5,3]) == 1
findIndex 6 (fromList [5,3])    Error: element is not in the set
valueelemAt :: Int -> Set a -> a
#

O(\log n). Retrieve an element by its index, i.e. by its zero-based index in the sorted sequence of elements. If the index is out of range (less than zero, greater or equal to size of the set), error is called.

elemAt 0 (fromList [5,3]) == 3
elemAt 1 (fromList [5,3]) == 5
elemAt 2 (fromList [5,3])    Error: index out of range
valuedeleteAt :: Int -> Set a -> Set a
#

O(\log n). Delete the element at index, i.e. by its zero-based index in the sorted sequence of elements. If the index is out of range (less than zero, greater or equal to size of the set), error is called.

deleteAt 0    (fromList [5,3]) == singleton 5
deleteAt 1    (fromList [5,3]) == singleton 3
deleteAt 2    (fromList [5,3])    Error: index out of range
deleteAt (-1) (fromList [5,3])    Error: index out of range

Min/Max

4 declarations
valuefindMin :: Set a -> a
#

O(\log n). The minimal element of a set.

valuefindMax :: Set a -> a
#

O(\log n). The maximal element of a set.

valuedeleteFindMin :: Set a -> (a, Set a)
#

O(\log n). Delete and find the minimal element.

deleteFindMin set = (findMin set, deleteMin set)
valuedeleteFindMax :: Set a -> (a, Set a)
#

O(\log n). Delete and find the maximal element.

deleteFindMax set = (findMax set, deleteMax set)