Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 8c2a233

Browse files
committed
Modify mappend to avoid discarding
1 parent 092dd89 commit 8c2a233

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 0.5.0
2+
3+
The behavior of `(<>)` for the `Ini` type has changed.
4+
5+
- `<>` previously discarded all `iniGlobals`. Now it concatenates
6+
the globals from the two `Ini` values.
7+
8+
- When two `Ini` values contained `iniSections` with the same name,
9+
`<>` previously returned the section from the left value and
10+
discarded the section of the same name from the right value.
11+
Now it concatenates the sections of the same name.
12+
113
## 0.4.2
214

315
_2022-07-26, Andreas Abel_

ini.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: >= 1.10
22
name: ini
3-
version: 0.4.2
3+
version: 0.5.0
44
synopsis: Configuration files in the INI format.
55
description: Quick and easy configuration files in the INI format.
66
license: BSD3

src/Data/Ini.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ data Ini =
8989
}
9090
deriving (Show, Eq)
9191

92+
-- | '<>' concatenates the lists of entries within each section (since @ini-0.5.0@)
9293
instance Semigroup Ini where
93-
x <> y = Ini {iniGlobals = mempty, iniSections = iniSections x <> iniSections y}
94+
x <> y =
95+
Ini
96+
{ iniGlobals = iniGlobals x ++ iniGlobals y
97+
, iniSections = M.unionWith (++) (iniSections x) (iniSections y)
98+
}
9499

95100
instance Monoid Ini where
96101
mempty = Ini {iniGlobals = mempty, iniSections = mempty}

0 commit comments

Comments
 (0)