json-api-lib 0.1.2.0 → 0.1.3.0
raw patch · 8 files changed
+49/−9 lines, 8 filesdep +deepseqdep ~lensPVP ok
version bump matches the API change (PVP)
Dependencies added: deepseq
Dependency ranges changed: lens
API changes (from Hackage documentation)
+ Network.JSONApi.Document: instance Control.DeepSeq.NFData Network.JSONApi.Document.Included
+ Network.JSONApi.Document: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Network.JSONApi.Document.Document a)
+ Network.JSONApi.Document: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Network.JSONApi.Document.ErrorDocument a)
+ Network.JSONApi.Document: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Network.JSONApi.Document.ResourceData a)
+ Network.JSONApi.Document: instance GHC.Generics.Generic Network.JSONApi.Document.Included
+ Network.JSONApi.Error: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Network.JSONApi.Error.Error a)
+ Network.JSONApi.Identifier: instance Control.DeepSeq.NFData Network.JSONApi.Identifier.Identifier
+ Network.JSONApi.Identifier: instance GHC.Generics.Generic Network.JSONApi.Identifier.Identifier
+ Network.JSONApi.Link: instance Control.DeepSeq.NFData Network.JSONApi.Link.Links
+ Network.JSONApi.Meta: instance Control.DeepSeq.NFData Network.JSONApi.Meta.Meta
+ Network.JSONApi.Pagination: instance Control.DeepSeq.NFData Network.JSONApi.Pagination.PageNum
+ Network.JSONApi.Pagination: instance Control.DeepSeq.NFData Network.JSONApi.Pagination.PageSize
+ Network.JSONApi.Pagination: instance Control.DeepSeq.NFData Network.JSONApi.Pagination.Pagination
+ Network.JSONApi.Pagination: instance Control.DeepSeq.NFData Network.JSONApi.Pagination.ResourceCount
+ Network.JSONApi.Pagination: instance GHC.Generics.Generic Network.JSONApi.Pagination.PageNum
+ Network.JSONApi.Pagination: instance GHC.Generics.Generic Network.JSONApi.Pagination.PageSize
+ Network.JSONApi.Pagination: instance GHC.Generics.Generic Network.JSONApi.Pagination.Pagination
+ Network.JSONApi.Pagination: instance GHC.Generics.Generic Network.JSONApi.Pagination.ResourceCount
+ Network.JSONApi.Resource: instance Control.DeepSeq.NFData Network.JSONApi.Resource.Relationship
+ Network.JSONApi.Resource: instance Control.DeepSeq.NFData Network.JSONApi.Resource.Relationships
+ Network.JSONApi.Resource: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Network.JSONApi.Resource.Resource a)
Files
- json-api-lib.cabal +4/−3
- src/Network/JSONApi/Document.hs +10/−1
- src/Network/JSONApi/Error.hs +2/−0
- src/Network/JSONApi/Identifier.hs +5/−1
- src/Network/JSONApi/Link.hs +3/−0
- src/Network/JSONApi/Meta.hs +2/−0
- src/Network/JSONApi/Pagination.hs +16/−4
- src/Network/JSONApi/Resource.hs +7/−0
json-api-lib.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.0 name: json-api-lib-version: 0.1.2.0+version: 0.1.3.0 homepage: https://github.com/shirren/json-api-lib bug-reports: https://github.com/shirren/json-api-lib/issues license: MIT@@ -26,7 +26,8 @@ , base >= 4.11 && < 5 , containers >= 0.6.1 && < 0.7 , data-default >= 0.7.1 && < 0.8- , lens >= 4.17.1 && < 4.19+ , deepseq >= 1.4 && < 1.5+ , lens >= 4.17.1 && < 4.20 , lens-aeson >= 1.0.2 && < 1.2 , text >= 1.2.3.1 && < 1.3 , unordered-containers >= 0.2.10 && < 0.3@@ -70,7 +71,7 @@ , data-default >= 0.7.1 && < 0.8 , hspec >= 2.7.1 && < 2.8 , json-api-lib- , lens >= 4.17.1 && < 4.19+ , lens >= 4.17.1 && < 4.20 , lens-aeson >= 1.0.2 && < 1.2 , text >= 1.2.3.1 && < 1.3 , unordered-containers >= 0.2.10 && < 0.3
src/Network/JSONApi/Document.hs view
@@ -17,6 +17,7 @@ , mkIncludedResource ) where +import Control.DeepSeq (NFData) import Control.Monad (mzero) import Data.Aeson ( ToJSON@@ -74,6 +75,8 @@ i <- v .: "included" return (Document d l m i) +instance (NFData a) => NFData (Document a)+ {- | The 'Included' type is an abstraction used to constrain the @included@ section of the Document to JSON serializable Resource objects while@@ -84,8 +87,10 @@ See 'mkIncludedResource' for creating 'Included' types. -} newtype Included = Included [Value]- deriving (Show)+ deriving (G.Generic, Show) +instance NFData Included+ {- | Constructor function for the Document data type. @@ -191,6 +196,8 @@ parseJSON (AE.Array v) = List <$> AE.parseJSON (AE.Array v) parseJSON _ = mzero +instance (NFData a) => NFData (ResourceData a)+ {- | The 'ErrorDocument' type represents the alternative form of the top-level JSON-API requirement.@@ -219,3 +226,5 @@ <$> v .: "error" <*> v .:? "links" <*> v .:? "meta"++instance (NFData a) => NFData (ErrorDocument a)
src/Network/JSONApi/Error.hs view
@@ -10,6 +10,7 @@ ( Error (..) ) where +import Control.DeepSeq (NFData) import Data.Aeson (ToJSON, FromJSON) import Data.Default import Data.Text@@ -37,6 +38,7 @@ instance ToJSON a => ToJSON (Error a) instance FromJSON a => FromJSON (Error a)+instance NFData a => NFData (Error a) instance Default (Error a) where def = Error
src/Network/JSONApi/Identifier.hs view
@@ -11,12 +11,15 @@ , metadata ) where +import Control.DeepSeq (NFData) import Control.Lens.TH import Data.Aeson (ToJSON, FromJSON, (.=), (.:), (.:?)) import qualified Data.Aeson as AE import Data.Text (Text) +import qualified GHC.Generics as G+ import Network.JSONApi.Meta (Meta) import Prelude hiding (id)@@ -33,7 +36,7 @@ { _ident :: Text , _datatype :: Text , _metadata :: Maybe Meta- } deriving (Show, Eq)+ } deriving (Show, Eq, G.Generic) instance ToJSON Identifier where toJSON (Identifier resId resType resMetaData) =@@ -49,6 +52,7 @@ meta <- v .:? "meta" return $ Identifier id typ meta +instance NFData Identifier {- | Typeclass indicating how to access an 'Identifier' for
src/Network/JSONApi/Link.hs view
@@ -10,6 +10,7 @@ , mkLinks ) where +import Control.DeepSeq (NFData) import Data.Aeson (ToJSON, FromJSON) import Data.Map (Map) import qualified Data.Map as Map@@ -34,6 +35,8 @@ -} newtype Links = Links (Map Rel Href) deriving (Show, Eq, Ord, ToJSON, FromJSON, G.Generic)++instance NFData Links type Rel = Text type Href = Text
src/Network/JSONApi/Meta.hs view
@@ -9,6 +9,7 @@ , mkMeta )where +import Control.DeepSeq (NFData) import Data.Aeson (ToJSON, FromJSON, Object, toJSON) import Data.HashMap.Strict as HM import Data.Text (Text)@@ -41,6 +42,7 @@ instance ToJSON Meta instance FromJSON Meta+instance NFData Meta {- | Convienience class for constructing a Meta type
src/Network/JSONApi/Pagination.hs view
@@ -5,8 +5,12 @@ , ResourceCount (..) ) where +import Control.DeepSeq (NFData)+ import Data.Aeson ((.=), ToJSON, object, toJSON) +import qualified GHC.Generics as G+ import Network.JSONApi.Meta (MetaObject (..)) {- |@@ -17,7 +21,7 @@ getPaginationPageSize :: PageSize , getPaginationPageNum :: PageNum , getPaginationResourceCount :: ResourceCount-}+} deriving (G.Generic) instance ToJSON Pagination where toJSON (Pagination (PageSize size) (PageNum num) (ResourceCount count)) =@@ -27,6 +31,8 @@ , "totalDocuments" .= count ] +instance NFData Pagination+ {- | Pagination can be used as a meta object if required in addition to the links generated for paging.@@ -39,12 +45,18 @@ -} newtype PageSize = PageSize { getPageSize :: Int-} deriving Show+} deriving (G.Generic, Show) +instance NFData PageSize+ newtype PageNum = PageNum { getPageNum :: Int-} deriving Show+} deriving (G.Generic, Show) +instance NFData PageNum+ newtype ResourceCount = ResourceCount { getResourceCount :: Int-} deriving Show+} deriving (G.Generic, Show)++instance NFData ResourceCount
src/Network/JSONApi/Resource.hs view
@@ -14,6 +14,8 @@ , showLink ) where +import Control.DeepSeq (NFData)+ import Control.Lens.TH import Data.Aeson (ToJSON, FromJSON, (.=), (.:), (.:?))@@ -70,6 +72,8 @@ instance HasIdentifier (Resource a) where identifier = getIdentifier +instance (NFData a) => NFData (Resource a)+ {- | A typeclass for decorating an entity with JSON API properties -}@@ -112,11 +116,14 @@ parseJSON = AE.genericParseJSON AE.defaultOptions { fieldLabelModifier = drop 1 } +instance NFData Relationship+ newtype Relationships = Relationships (Map Text Relationship) deriving (Show, Eq, Generic) instance ToJSON Relationships instance FromJSON Relationships+instance NFData Relationships mkRelationships :: Relationship -> Relationships mkRelationships rel =