Improve documentation for DA.TextMap.merge and DA.Next.Map.merge (#902)

Leave an explanation of what the functions is actually doing.
This commit is contained in:
Martin Huschenbett 2019-05-03 21:48:43 +02:00 committed by GitHub
parent 0ebdcb961e
commit 4df1ccfa13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -132,6 +132,10 @@ insert k v (Map t) = Map $ TextMap.insert (keyToText k) v t
union : MapKey k => Map k v -> Map k v -> Map k v
union (Map t1) (Map t2) = Map $ TextMap.union t1 t2
-- | Merge two maps. `merge f g h x y` applies `f` to all key/value pairs
-- whose key only appears in `x`, `g` to all pairs whose key only appears
-- in `y` and `h` to all pairs whose key appears in both `x` and `y`.
-- In the end, all pairs yielding `Some` are collected as the result.
merge
: MapKey k
=> (k -> a -> Optional c)

View File

@ -98,7 +98,10 @@ insert = primitive @"BEMapInsert"
union : TextMap a -> TextMap a -> TextMap a
union m1 m2 = foldl (\acc (k, v) -> insert k v acc) m2 (toList m1)
-- | Merge two maps.
-- | Merge two maps. `merge f g h x y` applies `f` to all key/value pairs
-- whose key only appears in `x`, `g` to all pairs whose key only appears
-- in `y` and `h` to all pairs whose key appears in both `x` and `y`.
-- In the end, all pairs yielding `Some` are collected as the result.
merge
: (Text -> a -> Optional c)
-> (Text -> b -> Optional c)