Skip to content

Commit 75275cf

Browse files
chore(server): allow building with aeson 2.0
The actual change is a bit cheesy, since we could have a non-CPP solution as well by adding a FromString constraint, but this one is stupid and simple. Additionally tested with both GHC 8.10.7, 9.0.1 and cabal v2-build --constraint='aeson >= 2.0' Increase version number to 1.0.0.1 (no observable changes) for a release that benefits Stackage Nightly mostly. Resolves #51.
1 parent 82d4aa4 commit 75275cf

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Revision history for spacecookie
22

3+
## 1.0.0.1
4+
5+
2021-11-29
6+
7+
This release fixes compilation with `aeson >= 2.0`.
8+
39
## 1.0.0.0
410

511
2021-03-16

server/Network/Spacecookie/Config.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE OverloadedStrings #-}
2+
{-# LANGUAGE CPP #-}
23
module Network.Spacecookie.Config
34
( Config (..)
45
, LogConfig (..)
@@ -23,7 +24,13 @@ data Config
2324
, logConfig :: LogConfig
2425
}
2526

27+
-- We only use string literals with 'maybePath', so we can just switch between
28+
-- Key and Text, since both have an IsString instance for OverloadedStrings.
29+
#if MIN_VERSION_aeson(2,0,0)
30+
maybePath :: FromJSON a => [Key] -> Object -> Parser (Maybe a)
31+
#else
2632
maybePath :: FromJSON a => [Text] -> Object -> Parser (Maybe a)
33+
#endif
2734
maybePath [] _ = fail "got empty path"
2835
maybePath [x] v = v .:? x
2936
maybePath (x:xs) v = v .:? x >>= fmap join . traverse (maybePath xs)

spacecookie.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: spacecookie
3-
version: 1.0.0.0
3+
version: 1.0.0.1
44
synopsis: Gopher server library and daemon
55
description: Simple gopher library that allows writing custom gopher
66
applications. Also includes a fully-featured gopher server
@@ -52,7 +52,7 @@ executable spacecookie
5252
import: common-settings, gopher-dependencies
5353
main-is: Main.hs
5454
build-depends: spacecookie
55-
, aeson >= 1.5 && < 2.0
55+
, aeson >= 1.5
5656
, systemd >= 2.1.0
5757
, fast-logger >= 2.4.0
5858
hs-source-dirs: server

0 commit comments

Comments
 (0)