git.iko.soy/typeable/servant
on master help sign in
Merge pull request #846 from phadej/pull-809-foreign-data
d04bd29Oleg Grenrus
servant-foreign/CHANGELOG.md+2
@@ -8,6 +8,8 @@
8
8
9* Add instances for `Description` and `Summary` combinators
9* Add instances for `Description` and `Summary` combinators
10 ([#767](https://github.com/haskell-servant/servant/pull/767))
10 ([#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))
11
13
120.10.1
140.10.1
13------
15------
servant-foreign/servant-foreign.cabal+5−5
@@ -47,21 +47,21 @@ library
47 if impl(ghc >= 8.0)
47 if impl(ghc >= 8.0)
48 ghc-options: -Wno-redundant-constraints
48 ghc-options: -Wno-redundant-constraints
49 include-dirs: include
49 include-dirs: include
50− default-extensions: CPP
50+ default-extensions: ConstraintKinds
51− , ConstraintKinds
51+ , CPP
52 , DataKinds
52 , DataKinds
53+ , DeriveDataTypeable
53 , FlexibleContexts
54 , FlexibleContexts
54 , FlexibleInstances
55 , FlexibleInstances
55 , GeneralizedNewtypeDeriving
56 , GeneralizedNewtypeDeriving
56 , MultiParamTypeClasses
57 , MultiParamTypeClasses
58+ , OverloadedStrings
59+ , PolyKinds
57 , ScopedTypeVariables
60 , ScopedTypeVariables
58− , StandaloneDeriving
59 , TemplateHaskell
61 , TemplateHaskell
60 , TypeFamilies
62 , TypeFamilies
61 , TypeOperators
63 , TypeOperators
62 , UndecidableInstances
64 , UndecidableInstances
63− , OverloadedStrings
64− , PolyKinds
65
65
66
66
67test-suite spec
67test-suite spec
servant-foreign/src/Servant/Foreign/Internal.hs+12−24
@@ -9,12 +9,14 @@ module Servant.Foreign.Internal where
9
9
10import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
10import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
11 (.~))
11 (.~))
12+import Data.Data (Data)
12#if !MIN_VERSION_base(4,8,0)
13#if !MIN_VERSION_base(4,8,0)
13import Data.Monoid
14import Data.Monoid
14#endif
15#endif
15import Data.Proxy
16import Data.Proxy
16import Data.String
17import Data.String
17import Data.Text
18import Data.Text
19+import Data.Typeable (Typeable)
18import Data.Text.Encoding (decodeUtf8)
20import Data.Text.Encoding (decodeUtf8)
19import GHC.TypeLits
21import GHC.TypeLits
20import qualified Network.HTTP.Types as HTTP
22import qualified Network.HTTP.Types as HTTP
@@ -24,21 +26,19 @@ import Servant.API.TypeLevel
24
26
25
27
26newtype FunctionName = FunctionName { unFunctionName :: [Text] }
28newtype FunctionName = FunctionName { unFunctionName :: [Text] }
27− deriving (Show, Eq, Monoid)
29+ deriving (Data, Show, Eq, Monoid, Typeable)
28
30
29makePrisms ''FunctionName
31makePrisms ''FunctionName
30
32
31newtype PathSegment = PathSegment { unPathSegment :: Text }
33newtype PathSegment = PathSegment { unPathSegment :: Text }
32− deriving (Show, Eq, IsString, Monoid)
34+ deriving (Data, Show, Eq, IsString, Monoid, Typeable)
33
35
34makePrisms ''PathSegment
36makePrisms ''PathSegment
35
37
36data Arg f = Arg
38data Arg f = Arg
37 { _argName :: PathSegment
39 { _argName :: PathSegment
38 , _argType :: f }
40 , _argType :: f }
39−
41+ deriving (Data, Eq, Show, Typeable)
40−deriving instance Eq f => Eq (Arg f)
41−deriving instance Show f => Show (Arg f)
42
42
43makeLenses ''Arg
43makeLenses ''Arg
44
44
@@ -50,16 +50,12 @@ data SegmentType f
50 -- ^ a static path segment. like "/foo"
50 -- ^ a static path segment. like "/foo"
51 | Cap (Arg f)
51 | Cap (Arg f)
52 -- ^ a capture. like "/:userid"
52 -- ^ a capture. like "/:userid"
53−
53+ deriving (Data, Eq, Show, Typeable)
54−deriving instance Eq f => Eq (SegmentType f)
55−deriving instance Show f => Show (SegmentType f)
56
54
57makePrisms ''SegmentType
55makePrisms ''SegmentType
58
56
59newtype Segment f = Segment { unSegment :: SegmentType f }
57newtype Segment f = Segment { unSegment :: SegmentType f }
60−
58+ deriving (Data, Eq, Show, Typeable)
61−deriving instance Eq f => Eq (Segment f)
62−deriving instance Show f => Show (Segment f)
63
59
64makePrisms ''Segment
60makePrisms ''Segment
65
61
@@ -77,7 +73,7 @@ data ArgType
77 = Normal
73 = Normal
78 | Flag
74 | Flag
79 | List
75 | List
80− deriving (Eq, Show)
76+ deriving (Data, Eq, Show, Typeable)
81
77
82makePrisms ''ArgType
78makePrisms ''ArgType
83
79
@@ -85,9 +81,7 @@ data QueryArg f = QueryArg
85 { _queryArgName :: Arg f
81 { _queryArgName :: Arg f
86 , _queryArgType :: ArgType
82 , _queryArgType :: ArgType
87 }
83 }
88−
84+ deriving (Data, Eq, Show, Typeable)
89−deriving instance Eq f => Eq (QueryArg f)
90−deriving instance Show f => Show (QueryArg f)
91
85
92makeLenses ''QueryArg
86makeLenses ''QueryArg
93
87
@@ -97,9 +91,7 @@ data HeaderArg f = HeaderArg
97 { _headerArg :: Arg f
91 { _headerArg :: Arg f
98 , _headerPattern :: Text
92 , _headerPattern :: Text
99 }
93 }
100−
94+ deriving (Data, Eq, Show, Typeable)
101−deriving instance Eq f => Eq (HeaderArg f)
102−deriving instance Show f => Show (HeaderArg f)
103
95
104makeLenses ''HeaderArg
96makeLenses ''HeaderArg
105
97
@@ -109,9 +101,7 @@ data Url f = Url
109 { _path :: Path f
101 { _path :: Path f
110 , _queryStr :: [QueryArg f]
102 , _queryStr :: [QueryArg f]
111 }
103 }
112−
104+ deriving (Data, Eq, Show, Typeable)
113−deriving instance Eq f => Eq (Url f)
114−deriving instance Show f => Show (Url f)
115
105
116defUrl :: Url f
106defUrl :: Url f
117defUrl = Url [] []
107defUrl = Url [] []
@@ -126,9 +116,7 @@ data Req f = Req
126 , _reqReturnType :: Maybe f
116 , _reqReturnType :: Maybe f
127 , _reqFuncName :: FunctionName
117 , _reqFuncName :: FunctionName
128 }
118 }
129−
119+ deriving (Data, Eq, Show, Typeable)
130−deriving instance Eq f => Eq (Req f)
131−deriving instance Show f => Show (Req f)
132
120
133makeLenses ''Req
121makeLenses ''Req
134
122
servant/CHANGELOG.md+9
@@ -21,6 +21,15 @@
21
21
22### Other changes
22### Other changes
23
23
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))
24- Allow newest dependencies
33- Allow newest dependencies
25 ([#772](https://github.com/haskell-servant/servant/pull/772)
34 ([#772](https://github.com/haskell-servant/servant/pull/772)
26 [#842](https://github.com/haskell-servant/servant/pull/842))
35 [#842](https://github.com/haskell-servant/servant/pull/842))