bcp47-orphans 0.1.0.5 → 0.1.0.6
raw patch · 4 files changed
+53/−18 lines, 4 filesdep +serialisedep ~QuickCheckdep ~bcp47dep ~cassavaPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies added: serialise
Dependency ranges changed: QuickCheck, bcp47, cassava, errors, esqueleto, hashable, hspec, http-api-data, path-pieces, persistent, text
API changes (from Hackage documentation)
+ Data.BCP47.Serialise: instance Codec.Serialise.Class.Serialise Data.BCP47.BCP47
Files
- ChangeLog.md +5/−1
- bcp47-orphans.cabal +21/−17
- library/Data/BCP47/Serialise.hs +12/−0
- tests/Data/BCP47/SerialiseSpec.hs +15/−0
ChangeLog.md view
@@ -1,6 +1,10 @@-## [*Unreleased*](https://github.com/freckle/bcp47/compare/bcp47-orphans-v0.1.0.5...main)+## [*Unreleased*](https://github.com/freckle/bcp47/compare/bcp47-orphans-v0.1.0.6...main) None++## [v0.1.0.5](https://github.com/freckle/bcp47/compare/bcp47-orphans-v0.1.0.5...bcp47-orphans-v0.1.0.6)++- Add support for Serialise and the CBOR format ## [v0.1.0.5](https://github.com/freckle/bcp47/compare/bcp47-orphans-v0.1.0.4...bcp47-orphans-v0.1.0.5)
bcp47-orphans.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: bcp47-orphans-version: 0.1.0.5+version: 0.1.0.6 license: MIT license-file: LICENSE copyright: 2019 Freckle Education@@ -28,21 +28,23 @@ Data.BCP47.HttpApiData Data.BCP47.PathPieces Data.BCP47.Persist+ Data.BCP47.Serialise hs-source-dirs: library other-modules: Paths_bcp47_orphans default-language: Haskell2010 build-depends: base >=4.7 && <5,- bcp47 >=0.2.0.6,- cassava >=0.5.1.0,- errors >=2.3.0,- esqueleto >=3.4.0.1,- hashable >=1.2.7.0,- http-api-data >=0.3.8.1,- path-pieces >=0.2.1,- persistent >=2.11.0.1,- text >=1.2.3.1+ bcp47,+ cassava,+ errors,+ esqueleto,+ hashable,+ http-api-data,+ path-pieces,+ persistent,+ serialise,+ text test-suite spec type: exitcode-stdio-1.0@@ -53,15 +55,17 @@ Data.BCP47.PathPiecesSpec Data.BCP47.PersistSpec Data.BCP47.Roundtrip+ Data.BCP47.SerialiseSpec Paths_bcp47_orphans default-language: Haskell2010 build-depends:- QuickCheck >=2.11.3,+ QuickCheck, base >=4.7 && <5,- bcp47 >=0.2.0.6,- bcp47-orphans -any,- cassava >=0.5.1.0,- hspec >=2.5.5,- path-pieces >=0.2.1,- persistent >=2.11.0.1+ bcp47,+ bcp47-orphans,+ cassava,+ hspec,+ path-pieces,+ persistent,+ serialise
+ library/Data/BCP47/Serialise.hs view
@@ -0,0 +1,12 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Data.BCP47.Serialise () where++import Codec.Serialise+import Data.BCP47 (BCP47, fromText, toText)+import Data.Text (unpack)++instance Serialise BCP47 where+ -- bypass children not having their own Serialise instances by using toText/fromText+ encode = encode . toText+ decode = either (fail . unpack) pure . fromText =<< decode
+ tests/Data/BCP47/SerialiseSpec.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE TypeApplications #-}++module Data.BCP47.SerialiseSpec+ ( spec+ ) where++import Codec.Serialise+import Data.BCP47 (BCP47)+import Data.BCP47.Serialise ()+import Test.Hspec+import Test.QuickCheck (property)++spec :: Spec+spec = describe "Serialise" . it "roundtrips" . property $ \x ->+ deserialise @BCP47 (serialise @BCP47 x) `shouldBe` x