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

Commit 21ed4e6

Browse files
committed
Modify mappend to avoid discarding
Closes #2
1 parent 092dd89 commit 21ed4e6

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 0.5.0
2+
3+
_2023-02-08, Chris Martin_
4+
5+
The behavior of `(<>)` for the `Ini` type has changed
6+
[#2](https://github.com/andreasabel/ini/issues/2)
7+
8+
- `<>` previously discarded all `iniGlobals`. Now it concatenates
9+
the globals from the two `Ini` values.
10+
11+
- When two `Ini` values contained `iniSections` with the same name,
12+
`<>` previously returned the section from the left value and
13+
discarded the section of the same name from the right value.
14+
Now it concatenates the sections of the same name.
15+
16+
Tested with GHC 7.0 - ghc-9.6.0.20230128.
17+
118
## 0.4.2
219

320
_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)