From 335e30be742fa0a9db28cf349365cd1eb10e60c1 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 20 Sep 2017 13:34:08 +0100 Subject: [PATCH 1/5] servant-foreign: Derive Data for all types --- servant-foreign/servant-foreign.cabal | 1 - .../src/Servant/Foreign/Internal.hs | 36 +++++++------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/servant-foreign/servant-foreign.cabal b/servant-foreign/servant-foreign.cabal index 91024033..a89aeff9 100644 --- a/servant-foreign/servant-foreign.cabal +++ b/servant-foreign/servant-foreign.cabal @@ -55,7 +55,6 @@ library , GeneralizedNewtypeDeriving , MultiParamTypeClasses , ScopedTypeVariables - , StandaloneDeriving , TemplateHaskell , TypeFamilies , TypeOperators diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index b0a3410f..aa72b25f 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveDataTypeable #-} #if !MIN_VERSION_base(4,8,0) {-# LANGUAGE NullaryTypeClasses #-} #endif @@ -9,6 +10,7 @@ module Servant.Foreign.Internal where import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~), (.~)) +import Data.Data #if !MIN_VERSION_base(4,8,0) import Data.Monoid #endif @@ -24,21 +26,19 @@ import Servant.API.TypeLevel newtype FunctionName = FunctionName { unFunctionName :: [Text] } - deriving (Show, Eq, Monoid) + deriving (Data, Show, Eq, Monoid) makePrisms ''FunctionName newtype PathSegment = PathSegment { unPathSegment :: Text } - deriving (Show, Eq, IsString, Monoid) + deriving (Data, Show, Eq, IsString, Monoid) makePrisms ''PathSegment data Arg f = Arg { _argName :: PathSegment , _argType :: f } - -deriving instance Eq f => Eq (Arg f) -deriving instance Show f => Show (Arg f) + deriving (Data, Eq, Show) makeLenses ''Arg @@ -50,16 +50,12 @@ data SegmentType f -- ^ a static path segment. like "/foo" | Cap (Arg f) -- ^ a capture. like "/:userid" - -deriving instance Eq f => Eq (SegmentType f) -deriving instance Show f => Show (SegmentType f) + deriving (Data, Eq, Show) makePrisms ''SegmentType newtype Segment f = Segment { unSegment :: SegmentType f } - -deriving instance Eq f => Eq (Segment f) -deriving instance Show f => Show (Segment f) + deriving (Data, Eq, Show) makePrisms ''Segment @@ -77,7 +73,7 @@ data ArgType = Normal | Flag | List - deriving (Eq, Show) + deriving (Data, Eq, Show) makePrisms ''ArgType @@ -85,9 +81,7 @@ data QueryArg f = QueryArg { _queryArgName :: Arg f , _queryArgType :: ArgType } - -deriving instance Eq f => Eq (QueryArg f) -deriving instance Show f => Show (QueryArg f) + deriving (Data, Eq, Show) makeLenses ''QueryArg @@ -97,9 +91,7 @@ data HeaderArg f = HeaderArg { _headerArg :: Arg f , _headerPattern :: Text } - -deriving instance Eq f => Eq (HeaderArg f) -deriving instance Show f => Show (HeaderArg f) + deriving (Data, Eq, Show) makeLenses ''HeaderArg @@ -109,9 +101,7 @@ data Url f = Url { _path :: Path f , _queryStr :: [QueryArg f] } - -deriving instance Eq f => Eq (Url f) -deriving instance Show f => Show (Url f) + deriving (Data, Eq, Show) defUrl :: Url f defUrl = Url [] [] @@ -126,9 +116,7 @@ data Req f = Req , _reqReturnType :: Maybe f , _reqFuncName :: FunctionName } - -deriving instance Eq f => Eq (Req f) -deriving instance Show f => Show (Req f) + deriving (Data, Eq, Show) makeLenses ''Req From 197d776e08d85a0bb008636a29b0276e81933de1 Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Wed, 20 Sep 2017 13:44:42 +0100 Subject: [PATCH 2/5] servant-foreign: Move -XDeriveDataTypeable to servant-foreign.cabal --- servant-foreign/servant-foreign.cabal | 9 +++++---- servant-foreign/src/Servant/Foreign/Internal.hs | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/servant-foreign/servant-foreign.cabal b/servant-foreign/servant-foreign.cabal index a89aeff9..93776a19 100644 --- a/servant-foreign/servant-foreign.cabal +++ b/servant-foreign/servant-foreign.cabal @@ -47,20 +47,21 @@ library if impl(ghc >= 8.0) ghc-options: -Wno-redundant-constraints include-dirs: include - default-extensions: CPP - , ConstraintKinds + default-extensions: ConstraintKinds + , CPP , DataKinds + , DeriveDataTypeable , FlexibleContexts , FlexibleInstances , GeneralizedNewtypeDeriving , MultiParamTypeClasses + , OverloadedStrings + , PolyKinds , ScopedTypeVariables , TemplateHaskell , TypeFamilies , TypeOperators , UndecidableInstances - , OverloadedStrings - , PolyKinds test-suite spec diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index aa72b25f..8cde7d52 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable #-} #if !MIN_VERSION_base(4,8,0) {-# LANGUAGE NullaryTypeClasses #-} #endif From bfe6f5b0a48428c1c0afc1c9c887671abb7f6465 Mon Sep 17 00:00:00 2001 From: Oliver Charles Date: Wed, 20 Sep 2017 16:53:52 +0100 Subject: [PATCH 3/5] servant-foreign: Explicitly import Data --- servant-foreign/src/Servant/Foreign/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index 8cde7d52..4a1674bc 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -9,7 +9,7 @@ module Servant.Foreign.Internal where import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~), (.~)) -import Data.Data +import Data.Data (Data) #if !MIN_VERSION_base(4,8,0) import Data.Monoid #endif From 80c6ba53479bde3d4b99a4650d7efd2fbb5bd98d Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Mon, 6 Nov 2017 12:29:43 +0200 Subject: [PATCH 4/5] Derive Typeable for internal servant-foreign types --- .../src/Servant/Foreign/Internal.hs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index 4a1674bc..3e85c25c 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -16,6 +16,7 @@ import Data.Monoid import Data.Proxy import Data.String import Data.Text +import Data.Typeable (Typeable) import Data.Text.Encoding (decodeUtf8) import GHC.TypeLits import qualified Network.HTTP.Types as HTTP @@ -25,19 +26,19 @@ import Servant.API.TypeLevel newtype FunctionName = FunctionName { unFunctionName :: [Text] } - deriving (Data, Show, Eq, Monoid) + deriving (Data, Show, Eq, Monoid, Typeable) makePrisms ''FunctionName newtype PathSegment = PathSegment { unPathSegment :: Text } - deriving (Data, Show, Eq, IsString, Monoid) + deriving (Data, Show, Eq, IsString, Monoid, Typeable) makePrisms ''PathSegment data Arg f = Arg { _argName :: PathSegment , _argType :: f } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makeLenses ''Arg @@ -49,12 +50,12 @@ data SegmentType f -- ^ a static path segment. like "/foo" | Cap (Arg f) -- ^ a capture. like "/:userid" - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makePrisms ''SegmentType newtype Segment f = Segment { unSegment :: SegmentType f } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makePrisms ''Segment @@ -72,7 +73,7 @@ data ArgType = Normal | Flag | List - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makePrisms ''ArgType @@ -80,7 +81,7 @@ data QueryArg f = QueryArg { _queryArgName :: Arg f , _queryArgType :: ArgType } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makeLenses ''QueryArg @@ -90,7 +91,7 @@ data HeaderArg f = HeaderArg { _headerArg :: Arg f , _headerPattern :: Text } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makeLenses ''HeaderArg @@ -100,7 +101,7 @@ data Url f = Url { _path :: Path f , _queryStr :: [QueryArg f] } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) defUrl :: Url f defUrl = Url [] [] @@ -115,7 +116,7 @@ data Req f = Req , _reqReturnType :: Maybe f , _reqFuncName :: FunctionName } - deriving (Data, Eq, Show) + deriving (Data, Eq, Show, Typeable) makeLenses ''Req From bba98a375533be647c1ee5673e6ec6017e92a82d Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Mon, 6 Nov 2017 12:35:43 +0200 Subject: [PATCH 5/5] Update changelogs --- servant-foreign/CHANGELOG.md | 2 ++ servant/CHANGELOG.md | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/servant-foreign/CHANGELOG.md b/servant-foreign/CHANGELOG.md index 00e98d49..e1a18626 100644 --- a/servant-foreign/CHANGELOG.md +++ b/servant-foreign/CHANGELOG.md @@ -8,6 +8,8 @@ * Add instances for `Description` and `Summary` combinators ([#767](https://github.com/haskell-servant/servant/pull/767)) +* Derive Data for all types + ([#809](https://github.com/haskell-servant/servant/pull/809)) 0.10.1 ------ diff --git a/servant/CHANGELOG.md b/servant/CHANGELOG.md index 69b5f9d6..1fe4c8c9 100644 --- a/servant/CHANGELOG.md +++ b/servant/CHANGELOG.md @@ -21,6 +21,15 @@ ### Other changes +- *servant-foreign* Derive `Data` for all types + ([#809](https://github.com/haskell-servant/servant/pull/809)) +- *servant-docs* Add authentication lenses + ([#787](https://github.com/haskell-servant/servant/pull/787)) +- *servant-docs* Generated markdown improvements + ([#813](https://github.com/haskell-servant/servant/pull/787) + [#767](https://github.com/haskell-servant/servant/pull/767) + [#790](https://github.com/haskell-servant/servant/pull/790) + [#788](https://github.com/haskell-servant/servant/pull/788)) - Allow newest dependencies ([#772](https://github.com/haskell-servant/servant/pull/772) [#842](https://github.com/haskell-servant/servant/pull/842))