Hoogle Search

Within LTS Haskell 24.60 (ghc-9.10.3)

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

  1. toList :: Map k a -> [(k, a)]

    containers Data.Map.Strict

    Convert the map to a list of key/value pairs. Subject to list fusion.

    toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
    toList empty == []
    

  2. fromAscList :: Eq k => [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from an ascending list in linear time. The precondition (input list is ascending) is not checked.

    fromAscList [(3,"b"), (5,"a")]          == fromList [(3, "b"), (5, "a")]
    fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
    valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True
    valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False
    

  3. fromAscListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from an ascending list in linear time with a combining function for equal keys. The precondition (input list is ascending) is not checked.

    fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
    valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True
    valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
    
    Also see the performance note on fromListWith.

  4. fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from an ascending list in linear time with a combining function for equal keys. The precondition (input list is ascending) is not checked.

    let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
    fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
    valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True
    valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
    
    Also see the performance note on fromListWith.

  5. fromDescList :: Eq k => [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from a descending list in linear time. The precondition (input list is descending) is not checked.

    fromDescList [(5,"a"), (3,"b")]          == fromList [(3, "b"), (5, "a")]
    fromDescList [(5,"a"), (5,"b"), (3,"a")] == fromList [(3, "b"), (5, "b")]
    valid (fromDescList [(5,"a"), (5,"b"), (3,"b")]) == True
    valid (fromDescList [(5,"a"), (3,"b"), (5,"b")]) == False
    

  6. fromDescListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from a descending list in linear time with a combining function for equal keys. The precondition (input list is descending) is not checked.

    fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "ba")]
    valid (fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")]) == True
    valid (fromDescListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
    
    Also see the performance note on fromListWith.

  7. fromDescListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from a descending list in linear time with a combining function for equal keys. The precondition (input list is descending) is not checked.

    let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
    fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
    valid (fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")]) == True
    valid (fromDescListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
    
    Also see the performance note on fromListWith.

  8. fromDistinctAscList :: [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from an ascending list of distinct elements in linear time. The precondition is not checked.

    fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
    valid (fromDistinctAscList [(3,"b"), (5,"a")])          == True
    valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == False
    

  9. fromDistinctDescList :: [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from a descending list of distinct elements in linear time. The precondition is not checked.

    fromDistinctDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")]
    valid (fromDistinctDescList [(5,"a"), (3,"b")])          == True
    valid (fromDistinctDescList [(5,"a"), (3,"b"), (3,"a")]) == False
    

  10. fromList :: Ord k => [(k, a)] -> Map k a

    containers Data.Map.Strict.Internal

    Build a map from a list of key/value pairs. See also fromAscList. If the list contains more than one value for the same key, the last value for the key is retained. If the keys of the list are ordered, a linear-time implementation is used.

    fromList [] == empty
    fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
    fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
    

Page 44 of many | Previous | Next