packages feed

hercules-ci-api-core 0.1.2.0 → 0.1.3.0

raw patch · 4 files changed

+79/−6 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Hercules.API.Prelude: data Placeholder
+ Hercules.API.Prelude: enterApiE :: forall subapi api mode a. (GenericServant (api a) mode, GenericServant (subapi a) mode) => api a mode -> (api a mode -> ToServant (subapi a) mode) -> subapi a mode
+ Hercules.API.Prelude: type family Substitute (target :: k) subapi :: *
+ Hercules.API.Servant: data Placeholder
+ Hercules.API.Servant: enterApi :: forall subapi api mode. (GenericServant api mode, GenericServant subapi mode) => api mode -> (api mode -> ToServant subapi mode) -> subapi mode
+ Hercules.API.Servant: enterApiE :: forall subapi api mode a. (GenericServant (api a) mode, GenericServant (subapi a) mode) => api a mode -> (api a mode -> ToServant (subapi a) mode) -> subapi a mode
+ Hercules.API.Servant: type family Substitute (target :: k) subapi :: *
+ Hercules.API.Servant: useApiE :: forall subapi api mode a. (GenericServant (api a) mode, GenericServant (subapi a) mode) => (api a mode -> ToServant (subapi a) mode) -> api a mode -> subapi a mode
- Hercules.API.Servant: useApi :: (GenericServant f mode, GenericServant g mode) => (f mode -> ToServant g mode) -> f mode -> g mode
+ Hercules.API.Servant: useApi :: forall subapi api mode. (GenericServant api mode, GenericServant subapi mode) => (api mode -> ToServant subapi mode) -> api mode -> subapi mode

Files

CHANGELOG.md view
@@ -4,6 +4,14 @@  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [0.1.3.0] - 2021-06-22++### Added++- Utilities for servant's `Generic` feature+  - `Substitute`+  - `useApiE`, `enterApi`, `enterApiE`+ ## [0.1.2.0] - 2020-03-07  - Use `uuid` type in swagger@@ -17,6 +25,8 @@  - Initial release, split out of hercules-ci-api +[0.1.3.0]: https://github.com/hercules-ci/hercules-ci-agent/releases/tag/hercules-ci-api-core-0.1.3.0+[0.1.2.0]: https://github.com/hercules-ci/hercules-ci-agent/releases/tag/hercules-ci-api-core-0.1.2.0 [0.1.1.0]: https://github.com/hercules-ci/hercules-ci-agent/releases/tag/hercules-ci-api-core-0.1.1.0 [0.1.0.0]: https://github.com/hercules-ci/hercules-ci-agent/releases/tag/hercules-ci-api-core-0.1.0.0 [Unreleased]: https://github.com/hercules-ci/hercules-ci-agent/compare/stable...master
hercules-ci-api-core.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12  name:           hercules-ci-api-core-version:        0.1.2.0+version:        0.1.3.0 synopsis:       Types and convenience modules use across Hercules CI API packages category:       API, CI, Testing, DevOps, Nix homepage:       https://github.com/hercules-ci/hercules-ci-agent#readme
src/Hercules/API/Prelude.hs view
@@ -19,6 +19,11 @@     FromJSON,     ToSchema,     schemaCompatibleOptions,++    -- * Servant+    Hercules.API.Servant.Substitute,+    Hercules.API.Servant.Placeholder,+    Hercules.API.Servant.enterApiE,   ) where @@ -37,6 +42,7 @@ import GHC.Generics (Generic) import Hercules.API.Id (Id) import Hercules.API.Name (Name)+import qualified Hercules.API.Servant import Prelude  schemaCompatibleOptions :: Aeson.Options
src/Hercules/API/Servant.hs view
@@ -1,6 +1,22 @@+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE TypeFamilies #-}+ -- | Extras for working with servant-module Hercules.API.Servant where+module Hercules.API.Servant+  ( noContent, +    -- * 'Generic'+    useApi,+    useApiE,+    enterApi,+    enterApiE,++    -- * Substitution+    Substitute,+    Placeholder,+  )+where+ import Control.Monad (void) import Servant.API import Servant.API.Generic@@ -12,15 +28,56 @@ -- -- Ideally, this functionality would be built into a new combinator. useApi ::-  (GenericServant f mode, GenericServant g mode) =>-  (f mode -> ToServant g mode) ->-  f mode ->-  g mode+  forall subapi api mode.+  (GenericServant api mode, GenericServant subapi mode) =>+  (api mode -> ToServant subapi mode) ->+  api mode ->+  subapi mode useApi = (Servant.API.Generic.fromServant .) +-- | Like 'useApi' but constrains the @auth@ type variable that's passed to+-- subapis.+useApiE ::+  forall subapi api mode a.+  (GenericServant (api a) mode, GenericServant (subapi a) mode) =>+  (api a mode -> ToServant (subapi a) mode) ->+  api a mode ->+  subapi a mode+useApiE = useApi++-- | @flip 'useApi'+enterApi ::+  forall subapi api mode.+  (GenericServant api mode, GenericServant subapi mode) =>+  api mode ->+  (api mode -> ToServant subapi mode) ->+  subapi mode+enterApi = flip useApi++-- | @flip 'useApiE'+enterApiE ::+  forall subapi api mode a.+  (GenericServant (api a) mode, GenericServant (subapi a) mode) =>+  api a mode ->+  (api a mode -> ToServant (subapi a) mode) ->+  subapi a mode+enterApiE = flip useApi+ -- | 'Control.Monad.void' specialised to 'NoContent' to soothe the -- compiler that rightfully warns about throwing away a do notation -- result. By specialising, we make sure that we still get warnings -- if the result type changes in the future. (We'll get an error) noContent :: Functor m => m Servant.API.NoContent -> m () noContent = void++-- | A reference to the @subapi@ parameter in 'Substitute'+data Placeholder++-- | Replaces 'Placeholder' by @subapi@ in the API @target@.+type family Substitute (target :: k) subapi :: *++type instance Substitute Placeholder subapi = subapi++type instance Substitute (a :> b) subapi = a :> Substitute b subapi++type instance Substitute (a :<|> b) subapi = Substitute a subapi :<|> Substitute b subapi