Hoogle Search

Within Stackage Nightly 2025-10-04 (ghc-9.12.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. data NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    A non-empty (by construction) set of integers. At least one value exists in an NEIntSet a at all times. Functions that take an NEIntSet can safely operate on it with the assumption that it has at least one item. Functions that return an NEIntSet provide an assurance that the result has at least one item. Data.IntSet.NonEmpty re-exports the API of Data.IntSet, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output sets are both non-empty (like insert) return NEIntSet, but functions that might potentially return an empty map (like delete) return a IntSet instead. You can directly construct an NEIntSet with the API from Data.IntSet.NonEmpty; it's more or less the same as constructing a normal IntSet, except you don't have access to empty. There are also a few ways to construct an NEIntSet from a IntSet:

    1. The nonEmptySet smart constructor will convert a IntSet a into a Maybe (NEIntSet a), returning Nothing if the original IntSet was empty.
    2. You can use the insertIntSet family of functions to insert a value into a IntSet to create a guaranteed NEIntSet.
    3. You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a IntSet to reveal it as either containing a NEIntSet or an empty map.
    4. withNonEmpty offers a continuation-based interface for deconstructing a IntSet and treating it as if it were an NEIntSet.
    You can convert an NEIntSet into a IntSet with toSet or IsNonEmpty, essentially "obscuring" the non-empty property from the type.

  2. insertSet :: Key -> IntSet -> NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(log n). Convert a IntSet into an NEIntSet by adding a value. Because of this, we know that the set must have at least one element, and so therefore cannot be empty. See insertSetMin for a version that is constant-time if the new value is strictly smaller than all values in the original set

    insertSet 4 (Data.IntSet.fromList [5, 3]) == fromList (3 :| [4, 5])
    insertSet 4 Data.IntSet.empty == singleton 4 "c"
    

  3. insertSetMax :: Key -> IntSet -> NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(log n) Convert a IntSet into an NEIntSet by adding a value where the value is strictly less than all values in the input set The values in the original map must all be strictly greater than the new value. The precondition is not checked. At the current moment, this is identical simply insertSet; however, it is left both for consistency and as a placeholder for a future version where optimizations are implemented to allow for a faster implementation.

    insertSetMin 7 (Data.IntSet.fromList [5, 3]) == fromList (3 :| [5, 7])
    

  4. insertSetMin :: Key -> IntSet -> NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(1) Convert a IntSet into an NEIntSet by adding a value where the value is strictly less than all values in the input set The values in the original map must all be strictly greater than the new value. The precondition is not checked.

    insertSetMin 2 (Data.IntSet.fromList [5, 3]) == fromList (2 :| [3, 5])
    valid (insertSetMin 2 (Data.IntSet.fromList [5, 3])) == True
    valid (insertSetMin 7 (Data.IntSet.fromList [5, 3])) == False
    valid (insertSetMin 3 (Data.IntSet.fromList [5, 3])) == False
    

  5. isProperSubsetOf :: NEIntSet -> NEIntSet -> Bool

    nonempty-containers Data.IntSet.NonEmpty

    O(n+m). Is this a proper subset? (ie. a subset but not equal).

  6. isSubsetOf :: NEIntSet -> NEIntSet -> Bool

    nonempty-containers Data.IntSet.NonEmpty

    O(n+m). Is this a subset? (s1 `isSubsetOf` s2) tells whether s1 is a subset of s2.

  7. nonEmptySet :: IntSet -> Maybe NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(log n). Smart constructor for an NEIntSet from a IntSet. Returns Nothing if the IntSet was originally actually empty, and Just n with an NEIntSet, if the IntSet was not empty. nonEmptySet and maybe empty toSet form an isomorphism: they are perfect structure-preserving inverses of eachother. See IsNonEmpty for a pattern synonym that lets you "match on" the possiblity of a IntSet being an NEIntSet.

    nonEmptySet (Data.IntSet.fromList [3,5]) == Just (fromList (3:|[5]))
    

  8. toSet :: NEIntSet -> IntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(log n). Convert a non-empty set back into a normal possibly-empty map, for usage with functions that expect IntSet. Can be thought of as "obscuring" the non-emptiness of the set in its type. See the IsNotEmpty pattern. nonEmptySet and maybe empty toSet form an isomorphism: they are perfect structure-preserving inverses of eachother.

    toSet (fromList ((3,"a") :| [(5,"b")])) == Data.IntSet.fromList [(3,"a"), (5,"b")]
    

  9. unsafeFromSet :: IntSet -> NEIntSet

    nonempty-containers Data.IntSet.NonEmpty

    O(log n). Unsafe version of nonEmptySet. Coerces a IntSet into an NEIntSet, but is undefined (throws a runtime exception when evaluation is attempted) for an empty IntSet.

  10. data NEIntSet

    nonempty-containers Data.IntSet.NonEmpty.Internal

    A non-empty (by construction) set of integers. At least one value exists in an NEIntSet a at all times. Functions that take an NEIntSet can safely operate on it with the assumption that it has at least one item. Functions that return an NEIntSet provide an assurance that the result has at least one item. Data.IntSet.NonEmpty re-exports the API of Data.IntSet, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output sets are both non-empty (like insert) return NEIntSet, but functions that might potentially return an empty map (like delete) return a IntSet instead. You can directly construct an NEIntSet with the API from Data.IntSet.NonEmpty; it's more or less the same as constructing a normal IntSet, except you don't have access to empty. There are also a few ways to construct an NEIntSet from a IntSet:

    1. The nonEmptySet smart constructor will convert a IntSet a into a Maybe (NEIntSet a), returning Nothing if the original IntSet was empty.
    2. You can use the insertIntSet family of functions to insert a value into a IntSet to create a guaranteed NEIntSet.
    3. You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a IntSet to reveal it as either containing a NEIntSet or an empty map.
    4. withNonEmpty offers a continuation-based interface for deconstructing a IntSet and treating it as if it were an NEIntSet.
    You can convert an NEIntSet into a IntSet with toSet or IsNonEmpty, essentially "obscuring" the non-empty property from the type.

Page 124 of many | Previous | Next