packages feed

json-spec 0.4.0.0 → 0.4.1.0

raw patch · 4 files changed

+30/−9 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.JsonSpec: type (::?) = 'Optional

Files

json-spec.cabal view
@@ -1,6 +1,6 @@ cabal-version:       3.0 name:                json-spec-version:             0.4.0.0+version:             0.4.1.0 synopsis:            Type-level JSON specification maintainer:          rick@owensmurray.com description:         See the README at: https://github.com/owensmurray/json-spec#json-spec
src/Data/JsonSpec.hs view
@@ -79,7 +79,9 @@   eitherDecode,   encode,   StructureFromJSON,-  FieldSpec(..)+  FieldSpec(..),+  (:::),+  (::?), ) where  @@ -91,8 +93,8 @@ import Data.JsonSpec.Spec (Field(Field, unField), FieldSpec(Optional,   Required), Rec(Rec, unRec), Specification(JsonArray, JsonBool,   JsonDateTime, JsonEither, JsonInt, JsonLet, JsonNullable, JsonNum,-  JsonObject, JsonRaw, JsonRef, JsonString, JsonTag), Tag(Tag),-  JSONStructure)+  JsonObject, JsonRaw, JsonRef, JsonString, JsonTag), Tag(Tag), (:::),+  (::?), JSONStructure) import Prelude ((.), (<$>), (=<<))  
src/Data/JsonSpec/Spec.hs view
@@ -16,6 +16,8 @@   Rec(..),   JStruct,   FieldSpec(..),+  (:::),+  (::?), ) where  @@ -177,6 +179,14 @@ data FieldSpec   = Required Symbol Specification {-^ The field is required -}   | Optional Symbol Specification {-^ The field is optionsl -}+++{-| Alias for 'Required'. -}+type (:::) = Required+++{-| Alias for 'Optional'. -}+type (::?) = Optional   {- |
test/jsonspec.hs view
@@ -11,19 +11,28 @@ {-# LANGUAGE ViewPatterns #-}  {-# OPTIONS_GHC -Wwarn #-} {- Because of GHC-69797 -}+{-# OPTIONS_GHC -Werror=missing-import-lists #-}  module Main (main) where  import Control.Monad (join) import Data.Aeson (FromJSON, ToJSON) import Data.ByteString.Lazy (ByteString)-import Data.JsonSpec +import Data.JsonSpec (Field(Field, unField), FieldSpec(Optional,+  Required), HasJsonDecodingSpec(DecodingSpec, fromJSONStructure),+  HasJsonEncodingSpec(EncodingSpec, toJSONStructure), Rec(Rec, unRec),+  SpecJSON(SpecJSON), Specification(JsonArray, JsonBool, JsonDateTime,+  JsonEither, JsonInt, JsonLet, JsonNullable, JsonNum, JsonObject,+  JsonRaw, JsonRef, JsonString, JsonTag), Tag(Tag), (:::), (::?),+  eitherDecode, encode) import Data.Proxy (Proxy(Proxy)) import Data.Scientific (Scientific) import Data.Text (Text) import Data.Time (UTCTime(UTCTime)) import OM.Show (ShowJ(ShowJ))-import Prelude +import Prelude (Applicative(pure), Bool(False, True), Either(Left,+  Right), Enum(toEnum), Functor(fmap), Maybe(Just, Nothing), Monad((>>=)),+  Traversable(traverse), ($), (.), Eq, IO, Int, Show, String, realToFrac) import Test.Hspec (describe, hspec, it, shouldBe) import qualified Data.Aeson as A @@ -364,7 +373,7 @@               A.eitherDecode                 "{ \"foo\": { \"bar\": \"barval\", \"baz\": [ \"qux\", 1, false ] } }"               >>=-                eitherDecode (Proxy @( JsonObject '[ Required "foo" JsonRaw ]))+                eitherDecode (Proxy @( JsonObject '[ "foo" ::: JsonRaw ]))           in             actual `shouldBe` expected         it "encodes" $@@ -389,8 +398,8 @@                   ())           in             actual `shouldBe` expected-           + sampleTestObject :: TestObj sampleTestObject =   TestObj@@ -677,7 +686,7 @@ instance HasJsonEncodingSpec TestOptionality where   type EncodingSpec TestOptionality =     JsonObject-      '[ Optional "foo" JsonInt+      '[ "foo" ::? JsonInt        , Required "bar" (JsonNullable JsonInt)        , Optional "baz" (JsonNullable JsonInt)        , Required "qux" JsonInt