From c4670d3c71225bb446e56ab1d55bb658beea476f Mon Sep 17 00:00:00 2001 From: bruderj15 Date: Tue, 29 Oct 2024 18:34:12 +0100 Subject: [PATCH 1/2] main: export CollectionItem, doc --- src/Servant/Hateoas/ContentType/Collection.hs | 11 ++++++----- src/Servant/Hateoas/ContentType/HAL.hs | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Servant/Hateoas/ContentType/Collection.hs b/src/Servant/Hateoas/ContentType/Collection.hs index 0ecab30..b3f81ae 100644 --- a/src/Servant/Hateoas/ContentType/Collection.hs +++ b/src/Servant/Hateoas/ContentType/Collection.hs @@ -6,6 +6,7 @@ module Servant.Hateoas.ContentType.Collection ( Collection , CollectionResource(..) +, CollectionItem(..) ) where @@ -28,15 +29,15 @@ data Collection (t :: Type) -- | Resource wrapper for 'Collection'. data CollectionResource a = CollectionResource - { href :: Maybe Link - , items :: [CollectionItem a] - , links :: [(String, Link)] + { href :: Maybe Link -- ^ Link to the collection + , items :: [CollectionItem a] -- ^ All items in the collection + , links :: [(String, Link)] -- ^ Pairs @(rel, link)@ for relations } deriving (Show, Generic) -- | A single item inside a 'CollectionResource'. data CollectionItem a = CollectionItem - { item :: a - , itemLinks :: [(String, Link)] + { item :: a -- ^ Wrapped item + , itemLinks :: [(String, Link)] -- ^ Links for the wrapped item } deriving (Show, Generic) instance Resource CollectionResource where diff --git a/src/Servant/Hateoas/ContentType/HAL.hs b/src/Servant/Hateoas/ContentType/HAL.hs index 38ed474..3694e5b 100644 --- a/src/Servant/Hateoas/ContentType/HAL.hs +++ b/src/Servant/Hateoas/ContentType/HAL.hs @@ -23,16 +23,16 @@ import GHC.TypeLits import GHC.Generics import GHC.Records --- | Data-Kind representing Content-Types with Hypertext Application Language (HAL). +-- | Data-Kind representing Content-Types of Hypertext Application Language (HAL). -- -- Type parameter @t@ is the mime type suffix in @application/hal+t@. data HAL (t :: Type) -- | Resource wrapper for HAL. data HALResource a = HALResource - { resource :: a - , links :: [(String, Link)] - , embedded :: [(String, SomeToJSON HALResource)] + { resource :: a -- ^ Wrapped resource + , links :: [(String, Link)] -- ^ Pairs @(rel, link)@ for relations + , embedded :: [(String, SomeToJSON HALResource)] -- ^ Pairs @(rel, resource)@ for embedded resources } deriving (Generic) instance Resource HALResource where From 908c34171e31ec1237e35d18d43f62f235d7a242 Mon Sep 17 00:00:00 2001 From: bruderj15 Date: Tue, 29 Oct 2024 18:36:09 +0100 Subject: [PATCH 2/2] main: bump version --- CHANGELOG.md | 7 ++++++- servant-hateoas.cabal | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 040fb98..f8c612d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PVP versioning](https://pvp.haskell.org/). +## v0.2.1 _(2024-10-25)_ + +### Changed +- Export `CollectionItem` +- Improved documentation + ## v0.2.0 _(2024-10-29)_ ### Added @@ -13,7 +19,6 @@ and this project adheres to [PVP versioning](https://pvp.haskell.org/). - Classes `EmbeddingResource res` & `CollectingResource res` for resource-modification ### Changed - - *(breaking change)* Renamed class `HasResource` to `Resource`, removed associated type and Content-Type param ## v0.1.1 _(2024-10-25)_ diff --git a/servant-hateoas.cabal b/servant-hateoas.cabal index c6de4b8..0c269a2 100644 --- a/servant-hateoas.cabal +++ b/servant-hateoas.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: servant-hateoas -version: 0.2.0 +version: 0.2.1 synopsis: HATEOAS extension for servant description: Create Resource-Representations for your types and make your API HATEOAS-compliant. Resource construction is generic where possible and manually adjustable where required.