Create a non empty set with one value.
Create a non empty set from a regular set and a given value.
In contrast to fromSet this will always return a value since there is always at least 1 value.
set = withValue 5 ( Set.fromList [ 4, 3 ] )
toSet set == Set.fromList [ 3, 4, 5 ]Same as Set.fromList except using a NotEmpty.List
Same as withValue but with a list instead of a set
Convert a regular set into a not empty set, or Nothing if the set is empty
fromSet ( Set.fromList [] ) == Nothing
fromSet ( Set.fromList [ 1, 2, 3 ] ) == Just ( fromListWithValue 1 [ 2, 3 ] )Convert a not empty set into a regular set
toSet ( fromListWithValue 1 [ 2, 3 ] ) == Set.fromList [ 1, 2, 3 ]
toSet ( singleton 1 ) == Set.singleton 1Extract the first value from a not empty set.
head ( fromListWithValue 1 [ 2, 3 ] ) == 1
head ( singleton 1 ) == 1Extract the last value from a not empty set.
head ( fromListWithValue 1 [ 2, 3 ] ) == 3
head ( singleton 1 ) == 1Returns the elements after the first value as a regular set
tail ( fromListWithValue 1 [ 2, 3 ] ) == Set.fromList [ 2, 3 ]
tail ( singleton 1 ) == Set.fromList []Returns wether the set has a tail with elements
hasTail ( fromListWithValue 1 [ 2, 3 ] ) == True
hasTail ( singleton 1 ) == False
hasTail ( fromListWithHead 1 [] ) == FalseSame as Set.remove but will return Nothing if the last value is removed
remove 1 ( fromListWithValue 1 [ 2, 3 ] ) == Just ( fromListWithValue 2 [ 3 ] )
remove 1 ( singleton 1 ) == Nothing
remove 2 ( singleton 1 ) == Just ( singleton 1 )Same as Set.filter but will return Nothing if no values satisfy the test
filter isKeyEven ( fromListWithValue 1 [ 2, 3 ] ) == Just ( fromListWithValue 2 [] )
filter isKeyEven ( singleton 1 ) == NothingSame as Set.diff but will return Nothing if the resulting set is empty
diff ( fromListWithValue 1 [ 2, 3 ] ) ( singleton 1 ) == Just ( fromListWithValue 2 2 [ ( 3, 3 ) ] )
diff ( singleton 1 ) ( singleton 1 ) == Nothing
diff ( singleton 2 ) ( singleton 1 ) == Just ( singleton 2 )Same as Set.intersect but will return Nothing if the resulting set is empty
intersect ( fromListWithValue 1 [ 2, 3 ] ) ( singleton 1 ) == Just ( fromListWithValue 1 1 [] )
intersect ( singleton 1 ) ( singleton 1 ) == Just ( singleton 1 )
intersect ( singleton 2 ) ( singleton 1 ) == NothingSame as Set.member
Same as Set.insert
Same as Set.size
Same as Set.map
Same as Set.foldl
Same as Set.foldr
Same as Set.toList
Same as Set.union
Not empty version of
Set