Haskell Language Containers - Data.Map Constructing


We can create a Map from a list of tuples like this:

Map.fromList [("Alex", 31), ("Bob", 22)]

A Map can also be constructed with a single value:

> Map.singleton "Alex" 31
fromList [("Alex",31)]

There is also the empty function.

empty :: Map k a

Data.Map also supports typical set operations such as union, difference and intersection.