Create a non empty dictionary with one key-value pair.
Create a non empty dictionary from a regular dictionary and a given pair.
In contrast to fromDict this will always return a value since there is always at least 1 pair.
dict = withPair 5 "Five" ( Dict.fromList [ ( 4, "Four" ), ( 3, "Three" ) ] )
toDict dict == Dict.fromList [ ( 3, "Three" ), ( 4, "Four" ), ( 5, "Five" ) ]Same as Dict.fromList except using a NotEmpty.List
Same as withPair but with a list or pairs instead of a dict
Convert a regular dict into a not empty dict, or Nothing if the dict is empty
fromDict ( Dict.fromList [] ) == Nothing
fromDict ( Dict.fromList [ ( 1, "one" ), ( 2, "two" ), ( 3, "three" ) ] ) == Just ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] )Convert a not empty dict into a regular dict
toDict ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == Dict.fromList [ ( 1, "one" ), ( 2, "two" ), ( 3, "three" ) ]
toDict ( singleton 1 "one" ) == Dict.fromList [ ( 1, "one" ) ]Extract the first pair from a not empty dictionary.
head ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == ( 1, "one" )
head ( singleton 1 "one" ) == ( 1, "one" )Extract the last pair from a not empty dictionary.
last ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == ( 3, "three" )
last ( singleton 1 "one" ) == ( 1, "one" )Returns the elements after the first pair as a regular dictionary
tail ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == Dict.fromList [ ( 2, "two" ), ( 3, "three" ) ]
tail ( singleton 1 "one" ) == Dict.fromList []Returns wether the dictionary has a tail with elements
hasTail ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == True
hasTail ( singleton 1 "one" ) == False
hasTail ( fromListWithHead 1 "one" [] ) == FalseSame as Dict.remove but will return Nothing if the last value is removed
remove 1 ( fromListWithPair 1 "one" [ ( 2, "two" ), ( 3, "three" ) ] ) == Just ( fromListWithPair 2 "two" [ ( 3, "three" ) ] )
remove 1 ( singleton 1 "one" ) == Nothing
remove 2 ( singleton 1 "one" ) == Just ( singleton 1 "one" )Same as Dict.filter but will return Nothing if no pairs satisfy the test
filter isKeyEven ( fromListWithPair 1 1 [ ( 2, 2 ), ( 3, 3 ) ] ) == Just ( fromListWithPair 2 2 [] )
filter isKeyEven ( singleton 1 1 ) == NothingSame as Dict.diff but will return Nothing if the resulting dictionary is empty
diff ( fromListWithPair 1 1 [ ( 2, 2 ), ( 3, 3 ) ] ) ( singleton 1 "one" ) == Just ( fromListWithPair 2 2 [ ( 3, 3 ) ] )
diff ( singleton 1 1 ) ( singleton 1 "one" ) == Nothing
diff ( singleton 2 2 ) ( singleton 1 "one" ) == Just ( singleton 2 2 )Same as Dict.intersect but will return Nothing if the resulting dictionary is empty
intersect ( fromListWithPair 1 1 [ ( 2, 2 ), ( 3, 3 ) ] ) ( singleton 1 "one" ) == Just ( fromListWithPair 1 1 [] )
intersect ( singleton 1 1 ) ( singleton 1 "one" ) == Just ( singleton 1 1 )
intersect ( singleton 2 2 ) ( singleton 1 "one" ) == NothingSame as Dict.get
Same as Dict.member
Same as Dict.insert
Same as Dict.size
Same as Dict.toList
Same as Dict.map
Same as Dict.foldl
Same as Dict.foldr
Same as Dict.union
Same as Dict.merge
Not empty version of
Dict