advent-of-code-api 0.2.4.1 → 0.2.4.2
raw patch · 3 files changed
+27/−2 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Advent.Types: instance Data.Aeson.Types.ToJSON.ToJSON Advent.Types.Day
+ Advent.Types: instance Data.Aeson.Types.ToJSON.ToJSON Advent.Types.Part
+ Advent.Types: instance Data.Aeson.Types.ToJSON.ToJSONKey Advent.Types.Day
+ Advent.Types: instance Data.Aeson.Types.ToJSON.ToJSONKey Advent.Types.Part
Files
- CHANGELOG.md +10/−0
- advent-of-code-api.cabal +2/−2
- src/Advent/Types.hs +15/−0
CHANGELOG.md view
@@ -1,6 +1,16 @@ Changelog ========= +Version 0.2.4.2+---------------++*November 23, 2019*++<https://github.com/mstksg/advent-of-code-api/releases/tag/v0.2.4.2>++* Added instances of `ToJSONKey Day`, `ToJSON Day`, `ToJSONKey Part`, `ToJSON+ Part`.+ Version 0.2.4.1 ---------------
advent-of-code-api.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 538919b3907c1f6fb7ea04cba6bb88a2137e0861598c39f023ab26534ae8d54f+-- hash: 00822f3b5bf4103c7c82e15d4dcec35343d1e6a293478fcfdb339c4a7c2ffba1 name: advent-of-code-api-version: 0.2.4.1+version: 0.2.4.2 synopsis: Advent of Code REST API bindings and servant API description: Haskell bindings for Advent of Code REST API and a servant API. Please use responsibly! See README.md or "Advent" module for an introduction and
src/Advent/Types.hs view
@@ -259,16 +259,31 @@ Nothing -> fail "bad stamp" Just i -> pure . posixSecondsToUTCTime $ fromInteger i +-- | @since 0.2.4.2+instance ToJSONKey Day where+ toJSONKey = toJSONKeyText $ T.pack . show . dayInt instance FromJSONKey Day where fromJSONKey = FromJSONKeyTextParser (parseJSON . String)+-- | @since 0.2.4.2+instance ToJSONKey Part where+ toJSONKey = toJSONKeyText $ \case+ Part1 -> "1"+ Part2 -> "2" instance FromJSONKey Part where fromJSONKey = FromJSONKeyTextParser (parseJSON . String) +-- | @since 0.2.4.2+instance ToJSON Part where+ toJSON = String . (\case Part1 -> "1"; Part2 -> "2") instance FromJSON Part where parseJSON = withText "Part" $ \case "1" -> pure Part1 "2" -> pure Part2 _ -> fail "Bad part"++-- | @since 0.2.4.2+instance ToJSON Day where+ toJSON = String . T.pack . show . dayInt instance FromJSON Day where parseJSON = withText "Day" $ \t -> case readMaybe (T.unpack t) of