packages feed

servant-foreign 0.10.2 → 0.11

raw patch · 5 files changed

+93/−60 lines, 5 filesdep +base-compatdep ~basedep ~hspecdep ~http-types

Dependencies added: base-compat

Dependency ranges changed: base, hspec, http-types, lens, servant, text

Files

CHANGELOG.md view
@@ -1,6 +1,16 @@ [The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant-foreign/CHANGELOG.md) [Changelog for `servant` package contains significant entries for all core packages.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md) +0.11+----++### Breaking changes++- *servant* Add `Servant.API.Modifiers`+  ([#873](https://github.com/haskell-servant/servant/pull/873))+- Make foreign client Header arguments have the representation of 'Maybe' in those languages+  ([#843](https://github.com/haskell-servant/servant/pull/843))+ 0.10.2 ------ 
servant-foreign.cabal view
@@ -1,5 +1,5 @@ name:                servant-foreign-version:             0.10.2+version:             0.11 synopsis:            Helpers for generating clients for servant APIs in any programming language description:   Helper types and functions for generating client functions for servant APIs in any programming language@@ -26,7 +26,7 @@   GHC==7.8.4   GHC==7.10.3   GHC==8.0.2-  GHC==8.2.1+  GHC==8.2.2  source-repository head   type: git@@ -36,34 +36,33 @@   exposed-modules:     Servant.Foreign                      , Servant.Foreign.Internal                      , Servant.Foreign.Inflections-  build-depends:       base       == 4.*-                     , lens       == 4.*-                     , servant    == 0.12.*-                     , text       >= 1.2  && < 1.3-                     , http-types++  -- Bundled with GHC: Lower bound to not force re-installs+  -- text and mtl are bundled starting with GHC-8.4+  --+  -- note: mtl lower bound is so low because of GHC-7.8+  build-depends:+      base        >= 4.7     && <4.11+    , text        >= 1.2.3.0 && < 1.3++  -- Servant dependencies+  build-depends:+      servant            == 0.13.*++  -- Other dependencies: Lower bound around what is in the latest Stackage LTS.+  -- Here can be exceptions if we really need features from the newer versions.+  build-depends:+      base-compat >= 0.9.3  && <0.10+    , lens        >= 4.15.4 && <4.17+    , http-types  >= 0.12   && < 0.13+   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall   if impl(ghc >= 8.0)     ghc-options: -Wno-redundant-constraints   include-dirs: include-  default-extensions:  ConstraintKinds-                     , CPP-                     , DataKinds-                     , DeriveDataTypeable-                     , FlexibleContexts-                     , FlexibleInstances-                     , GeneralizedNewtypeDeriving-                     , MultiParamTypeClasses-                     , OverloadedStrings-                     , PolyKinds-                     , ScopedTypeVariables-                     , TemplateHaskell-                     , TypeFamilies-                     , TypeOperators-                     , UndecidableInstances - test-suite spec   type:              exitcode-stdio-1.0   hs-source-dirs:    test@@ -71,22 +70,17 @@   include-dirs:      include   main-is:           Spec.hs   other-modules:     Servant.ForeignSpec++  -- Dependencies inherited from the library. No need to specify bounds.+  build-depends:+      base+    , servant+    , servant-foreign++  -- Additonal dependencies+  build-depends:+    hspec >= 2.4.4 && <2.5+   build-tool-depends:-    hspec-discover:hspec-discover-  build-depends:     base-                   , hspec >= 2.1.8-                   , servant-                   , servant-foreign+    hspec-discover:hspec-discover >=2.4.4 && <2.5   default-language:  Haskell2010-  default-extensions:  ConstraintKinds-                     , DataKinds-                     , FlexibleContexts-                     , FlexibleInstances-                     , GeneralizedNewtypeDeriving-                     , MultiParamTypeClasses-                     , ScopedTypeVariables-                     , TypeFamilies-                     , TypeOperators-                     , UndecidableInstances-                     , OverloadedStrings-                     , PolyKinds
src/Servant/Foreign/Inflections.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-} module Servant.Foreign.Inflections   ( concatCase   , snakeCase
src/Servant/Foreign/Internal.hs view
@@ -1,4 +1,17 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses  #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-} #if !MIN_VERSION_base(4,8,0) {-# LANGUAGE NullaryTypeClasses #-} #endif@@ -7,12 +20,12 @@ -- arbitrary programming languages. module Servant.Foreign.Internal where +import Prelude ()+import Prelude.Compat+ import           Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),                                (.~)) import           Data.Data (Data)-#if !MIN_VERSION_base(4,8,0)-import           Data.Monoid-#endif import           Data.Proxy import           Data.String import           Data.Text@@ -20,10 +33,9 @@ import           Data.Text.Encoding (decodeUtf8) import           GHC.TypeLits import qualified Network.HTTP.Types as HTTP-import           Prelude hiding (concat) import           Servant.API import           Servant.API.TypeLevel-+import           Servant.API.Modifiers (RequiredArgument)  newtype FunctionName = FunctionName { unFunctionName :: [Text] }   deriving (Data, Show, Eq, Monoid, Typeable)@@ -183,8 +195,8 @@   foreignFor Proxy Proxy Proxy _ = EmptyForeignAPI  instance (KnownSymbol sym, HasForeignType lang ftype t, HasForeign lang ftype api)-  => HasForeign lang ftype (Capture sym t :> api) where-  type Foreign ftype (Capture sym t :> api) = Foreign ftype api+  => HasForeign lang ftype (Capture' mods sym t :> api) where+  type Foreign ftype (Capture' mods sym t :> api) = Foreign ftype api    foreignFor lang Proxy Proxy req =     foreignFor lang Proxy (Proxy :: Proxy api) $@@ -225,9 +237,9 @@       method   = reflectMethod (Proxy :: Proxy method)       methodLC = toLower $ decodeUtf8 method -instance (KnownSymbol sym, HasForeignType lang ftype a, HasForeign lang ftype api)-  => HasForeign lang ftype (Header sym a :> api) where-  type Foreign ftype (Header sym a :> api) = Foreign ftype api+instance (KnownSymbol sym, HasForeignType lang ftype (RequiredArgument mods a), HasForeign lang ftype api)+  => HasForeign lang ftype (Header' mods sym a :> api) where+  type Foreign ftype (Header' mods sym a :> api) = Foreign ftype api    foreignFor lang Proxy Proxy req =     foreignFor lang Proxy subP $ req & reqHeaders <>~ [HeaderArg arg]@@ -235,12 +247,12 @@       hname = pack . symbolVal $ (Proxy :: Proxy sym)       arg   = Arg         { _argName = PathSegment hname-        , _argType  = typeFor lang (Proxy :: Proxy ftype) (Proxy :: Proxy a) }+        , _argType  = typeFor lang (Proxy :: Proxy ftype) (Proxy :: Proxy (RequiredArgument mods a)) }       subP  = Proxy :: Proxy api -instance (KnownSymbol sym, HasForeignType lang ftype a, HasForeign lang ftype api)-  => HasForeign lang ftype (QueryParam sym a :> api) where-  type Foreign ftype (QueryParam sym a :> api) = Foreign ftype api+instance (KnownSymbol sym, HasForeignType lang ftype (RequiredArgument mods a), HasForeign lang ftype api)+  => HasForeign lang ftype (QueryParam' mods sym a :> api) where+  type Foreign ftype (QueryParam' mods sym a :> api) = Foreign ftype api    foreignFor lang Proxy Proxy req =     foreignFor lang (Proxy :: Proxy ftype) (Proxy :: Proxy api) $@@ -249,7 +261,7 @@       str = pack . symbolVal $ (Proxy :: Proxy sym)       arg = Arg         { _argName = PathSegment str-        , _argType = typeFor lang (Proxy :: Proxy ftype) (Proxy :: Proxy a) }+        , _argType = typeFor lang (Proxy :: Proxy ftype) (Proxy :: Proxy (RequiredArgument mods a)) }  instance   (KnownSymbol sym, HasForeignType lang ftype [a], HasForeign lang ftype api)@@ -286,8 +298,8 @@         & reqMethod .~ method  instance (Elem JSON list, HasForeignType lang ftype a, HasForeign lang ftype api)-      => HasForeign lang ftype (ReqBody list a :> api) where-  type Foreign ftype (ReqBody list a :> api) = Foreign ftype api+      => HasForeign lang ftype (ReqBody' mods list a :> api) where+  type Foreign ftype (ReqBody' mods list a :> api) = Foreign ftype api    foreignFor lang ftype Proxy req =     foreignFor lang ftype (Proxy :: Proxy api) $
test/Servant/ForeignSpec.hs view
@@ -1,4 +1,17 @@-{-# LANGUAGE CPP               #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses  #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+#if __GLASGOW_HASKELL__ < 709+{-# OPTIONS_GHC -fcontext-stack=41 #-}+#endif #include "overlapping-compat.h"  module Servant.ForeignSpec where@@ -51,6 +64,9 @@ instance OVERLAPPABLE_ HasForeignType LangX String a => HasForeignType LangX String [a] where   typeFor lang ftype _ = "listX of " <> typeFor lang ftype (Proxy :: Proxy a) +instance (HasForeignType LangX String a) => HasForeignType LangX String (Maybe a) where+  typeFor lang ftype _ = "maybe " <> typeFor lang ftype (Proxy :: Proxy a)+ type TestApi     = "test" :> Header "header" [String] :> QueryFlag "flag" :> Get '[JSON] Int  :<|> "test" :> QueryParam "param" Int :> ReqBody '[JSON] [String] :> Post '[JSON] NoContent@@ -75,7 +91,7 @@           [ Segment $ Static "test" ]           [ QueryArg (Arg "flag" "boolX") Flag ]       , _reqMethod     = "GET"-      , _reqHeaders    = [HeaderArg $ Arg "header" "listX of stringX"]+      , _reqHeaders    = [HeaderArg $ Arg "header" "maybe listX of stringX"]       , _reqBody       = Nothing       , _reqReturnType = Just "intX"       , _reqFuncName   = FunctionName ["get", "test"]@@ -85,7 +101,7 @@     shouldBe postReq $ defReq       { _reqUrl        = Url           [ Segment $ Static "test" ]-          [ QueryArg (Arg "param" "intX") Normal ]+          [ QueryArg (Arg "param" "maybe intX") Normal ]       , _reqMethod     = "POST"       , _reqHeaders    = []       , _reqBody       = Just "listX of stringX"