-- This is a version of Map.fromList that checks that there are no
-- duplicate keys in the input association list.

toMap :: (Ord k, Show k) => [(k, a)] -> Map k a
toMap assoc =
    let keys = map fst assoc
        dups = nub (keys \\ nub keys)
    in if null dups then fromList assoc
       else bug ("Duplicate keys " ++ show dups)
toMap :: (Ord k, Show k) => [(k, a)] -> Map k a
toMap assoc =
    let keys = map fst assoc
        dups = nub (keys \\ nub keys)
    in if null dups then fromList assoc
       else bug ("Duplicate keys " ++ show dups)
toMap assoc =
    let keys = map fst assoc
        dups = nub (keys \\ nub keys)
    in if null dups then fromList assoc
       else bug ("Duplicate keys " ++ show dups)