Hoogle Search

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

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

  1. toSet :: NEIntSet -> IntSet

    nonempty-containers Data.IntSet.NonEmpty.Internal

    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")]
    

  2. fromSet :: (k -> a) -> NESet k -> NEMap k a

    nonempty-containers Data.Map.NonEmpty

    O(n). Build a non-empty map from a non-empty set of keys and a function which for each key computes its value.

    fromSet (\k -> replicate k 'a') (Data.Set.NonEmpty.fromList (3 :| [5])) == fromList ((5,"aaaaa") :| [(3,"aaa")])
    

  3. keysSet :: NEMap k a -> NESet k

    nonempty-containers Data.Map.NonEmpty

    O(n). The non-empty set of all keys of the map.

    keysSet (fromList ((5,"a") :| [(3,"b")])) == Data.Set.NonEmpty.fromList (3 :| [5])
    

  4. data NESet a

    nonempty-containers Data.Set.NonEmpty

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

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

  5. insertSet :: Ord a => a -> Set a -> NESet a

    nonempty-containers Data.Set.NonEmpty

    O(log n). Convert a Set into an NESet 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.Set.fromList [5, 3]) == fromList (3 :| [4, 5])
    insertSet 4 Data.Set.empty == singleton 4 "c"
    

  6. insertSetMax :: a -> Set a -> NESet a

    nonempty-containers Data.Set.NonEmpty

    O(log n) Convert a Set into an NESet 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. While this has the same asymptotics as insertSet, it saves a constant factor for key comparison (so may be helpful if comparison is expensive) and also does not require an Ord instance for the key type.

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

  7. insertSetMin :: a -> Set a -> NESet a

    nonempty-containers Data.Set.NonEmpty

    O(1) Convert a Set into an NESet 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.Set.fromList [5, 3]) == fromList (2 :| [3, 5])
    valid (insertSetMin 2 (Data.Set.fromList [5, 3])) == True
    valid (insertSetMin 7 (Data.Set.fromList [5, 3])) == False
    valid (insertSetMin 3 (Data.Set.fromList [5, 3])) == False
    

  8. isProperSubsetOf :: Ord a => NESet a -> NESet a -> Bool

    nonempty-containers Data.Set.NonEmpty

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

  9. isSubsetOf :: Ord a => NESet a -> NESet a -> Bool

    nonempty-containers Data.Set.NonEmpty

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

  10. nonEmptySet :: Set a -> Maybe (NESet a)

    nonempty-containers Data.Set.NonEmpty

    O(log n). Smart constructor for an NESet from a Set. Returns Nothing if the Set was originally actually empty, and Just n with an NESet, if the Set 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 Set being an NESet.

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

Page 128 of many | Previous | Next