Skip to content

Commit 18f4e23

Browse files
chris-martintreeowl
authored andcommitted
Document the Semigroup for Map
The Map type has many possible semigroup implementations, so the documentation needs to explain which one was chosen.
1 parent 23a3656 commit 18f4e23

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Data/Map/Internal.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ m1 \\ m2 = difference m1 m2
463463
Size balanced trees.
464464
--------------------------------------------------------------------}
465465
-- | A Map from keys @k@ to values @a@.
466+
--
467+
-- The 'Semigroup' operation for 'Map' is 'union', which prefers
468+
-- values from the left operand. If @m1@ maps a key @k@ to a value
469+
-- @a1@, and @m2@ maps the same key to a different value @a2@, then
470+
-- their union @m1 <> m2@ maps @k@ to @a1@.
466471

467472
-- See Note: Order of constructors
468473
data Map k a = Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a)

0 commit comments

Comments
 (0)