git.iko.soy/typeable/servant
on master help sign in
Merge pull request #846 from phadej/pull-809-foreign-data

Pull 809 foreign data

commitd04bd290c5bb3140d60a5d687a2ac541c8f37545 authorOleg Grenrus <oleg.grenrus@iki.fi> dateMon 6 Nov 2017, 13:04 (9 years ago) parentb7b6ce7bba98a3
4 files changed+28−29
servant-foreign/CHANGELOG.md+2 servant-foreign/servant-foreign.cabal+5−5 servant-foreign/src/Servant/Foreign/Internal.hs+12−24 servant/CHANGELOG.md+9
servant-foreign/CHANGELOG.md+2
@@ -8,6 +8,8 @@
88
99* Add instances for `Description` and `Summary` combinators
1010 ([#767](https://github.com/haskell-servant/servant/pull/767))
11+* Derive Data for all types
12+ ([#809](https://github.com/haskell-servant/servant/pull/809))
1113
12140.10.1
1315------
servant-foreign/servant-foreign.cabal+5−5
@@ -47,21 +47,21 @@ library
4747 if impl(ghc >= 8.0)
4848 ghc-options: -Wno-redundant-constraints
4949 include-dirs: include
50− default-extensions: CPP
51− , ConstraintKinds
50+ default-extensions: ConstraintKinds
51+ , CPP
5252 , DataKinds
53+ , DeriveDataTypeable
5354 , FlexibleContexts
5455 , FlexibleInstances
5556 , GeneralizedNewtypeDeriving
5657 , MultiParamTypeClasses
58+ , OverloadedStrings
59+ , PolyKinds
5760 , ScopedTypeVariables
58− , StandaloneDeriving
5961 , TemplateHaskell
6062 , TypeFamilies
6163 , TypeOperators
6264 , UndecidableInstances
63− , OverloadedStrings
64− , PolyKinds
6565
6666
6767test-suite spec
servant-foreign/src/Servant/Foreign/Internal.hs+12−24
@@ -9,12 +9,14 @@ module Servant.Foreign.Internal where
99
1010import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
1111 (.~))
12+import Data.Data (Data)
1213#if !MIN_VERSION_base(4,8,0)
1314import Data.Monoid
1415#endif
1516import Data.Proxy
1617import Data.String
1718import Data.Text
19+import Data.Typeable (Typeable)
1820import Data.Text.Encoding (decodeUtf8)
1921import GHC.TypeLits
2022import qualified Network.HTTP.Types as HTTP
@@ -24,21 +26,19 @@ import Servant.API.TypeLevel
2426
2527
2628newtype FunctionName = FunctionName { unFunctionName :: [Text] }
27− deriving (Show, Eq, Monoid)
29+ deriving (Data, Show, Eq, Monoid, Typeable)
2830
2931makePrisms ''FunctionName
3032
3133newtype PathSegment = PathSegment { unPathSegment :: Text }
32− deriving (Show, Eq, IsString, Monoid)
34+ deriving (Data, Show, Eq, IsString, Monoid, Typeable)
3335
3436makePrisms ''PathSegment
3537
3638data Arg f = Arg
3739 { _argName :: PathSegment
3840 , _argType :: f }
39−
40−deriving instance Eq f => Eq (Arg f)
41−deriving instance Show f => Show (Arg f)
41+ deriving (Data, Eq, Show, Typeable)
4242
4343makeLenses ''Arg
4444
@@ -50,16 +50,12 @@ data SegmentType f
5050 -- ^ a static path segment. like "/foo"
5151 | Cap (Arg f)
5252 -- ^ a capture. like "/:userid"
53−
54−deriving instance Eq f => Eq (SegmentType f)
55−deriving instance Show f => Show (SegmentType f)
53+ deriving (Data, Eq, Show, Typeable)
5654
5755makePrisms ''SegmentType
5856
5957newtype Segment f = Segment { unSegment :: SegmentType f }
60−
61−deriving instance Eq f => Eq (Segment f)
62−deriving instance Show f => Show (Segment f)
58+ deriving (Data, Eq, Show, Typeable)
6359
6460makePrisms ''Segment
6561
@@ -77,7 +73,7 @@ data ArgType
7773 = Normal
7874 | Flag
7975 | List
80− deriving (Eq, Show)
76+ deriving (Data, Eq, Show, Typeable)
8177
8278makePrisms ''ArgType
8379
@@ -85,9 +81,7 @@ data QueryArg f = QueryArg
8581 { _queryArgName :: Arg f
8682 , _queryArgType :: ArgType
8783 }
88−
89−deriving instance Eq f => Eq (QueryArg f)
90−deriving instance Show f => Show (QueryArg f)
84+ deriving (Data, Eq, Show, Typeable)
9185
9286makeLenses ''QueryArg
9387
@@ -97,9 +91,7 @@ data HeaderArg f = HeaderArg
9791 { _headerArg :: Arg f
9892 , _headerPattern :: Text
9993 }
100−
101−deriving instance Eq f => Eq (HeaderArg f)
102−deriving instance Show f => Show (HeaderArg f)
94+ deriving (Data, Eq, Show, Typeable)
10395
10496makeLenses ''HeaderArg
10597
@@ -109,9 +101,7 @@ data Url f = Url
109101 { _path :: Path f
110102 , _queryStr :: [QueryArg f]
111103 }
112−
113−deriving instance Eq f => Eq (Url f)
114−deriving instance Show f => Show (Url f)
104+ deriving (Data, Eq, Show, Typeable)
115105
116106defUrl :: Url f
117107defUrl = Url [] []
@@ -126,9 +116,7 @@ data Req f = Req
126116 , _reqReturnType :: Maybe f
127117 , _reqFuncName :: FunctionName
128118 }
129−
130−deriving instance Eq f => Eq (Req f)
131−deriving instance Show f => Show (Req f)
119+ deriving (Data, Eq, Show, Typeable)
132120
133121makeLenses ''Req
134122
servant/CHANGELOG.md+9
@@ -21,6 +21,15 @@
2121
2222### Other changes
2323
24+- *servant-foreign* Derive `Data` for all types
25+ ([#809](https://github.com/haskell-servant/servant/pull/809))
26+- *servant-docs* Add authentication lenses
27+ ([#787](https://github.com/haskell-servant/servant/pull/787))
28+- *servant-docs* Generated markdown improvements
29+ ([#813](https://github.com/haskell-servant/servant/pull/787)
30+ [#767](https://github.com/haskell-servant/servant/pull/767)
31+ [#790](https://github.com/haskell-servant/servant/pull/790)
32+ [#788](https://github.com/haskell-servant/servant/pull/788))
2433- Allow newest dependencies
2534 ([#772](https://github.com/haskell-servant/servant/pull/772)
2635 [#842](https://github.com/haskell-servant/servant/pull/842))