Hoogle Search

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

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

  1. 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
    

  2. 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
    

  3. 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).

  4. 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.

  5. 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]))
    

  6. powerSet :: NESet a -> NESet (NESet a)

    nonempty-containers Data.Set.NonEmpty

    Calculate the power set of a non-empty: the set of all its (non-empty) subsets.

    t `member` powerSet s == t `isSubsetOf` s
    
    Example:
    powerSet (fromList (1 :| [2,3])) =
    fromList (singleton 1 :| [ singleton 2
    , singleton 3
    , fromList (1 :| [2])
    , fromList (1 :| [3])
    , fromList (2 :| [3])
    , fromList (1 :| [2,3])
    ]
    )
    
    We know that the result is non-empty because the result will always at least contain the original set.

  7. toSet :: NESet a -> Set a

    nonempty-containers Data.Set.NonEmpty

    O(log n). Convert a non-empty set back into a normal possibly-empty map, for usage with functions that expect Set. 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.Set.fromList [(3,"a"), (5,"b")]
    

  8. unsafeFromSet :: Set a -> NESet a

    nonempty-containers Data.Set.NonEmpty

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

  9. newtype MergeNESet a

    nonempty-containers Data.Set.NonEmpty.Internal

    Used for cartesianProduct

  10. MergeNESet :: NESet a -> MergeNESet a

    nonempty-containers Data.Set.NonEmpty.Internal

    No documentation available.

Page 126 of many | Previous | Next