git.iko.soy/typeable/servant
on master help sign in
servant-foreign: Derive Data for all types
commit335e30be742fa0a9db28cf349365cd1eb10e60c1 authorOllie Charles <ollie@ocharles.org.uk> dateWed 20 Sep 2017, 13:34 (9 years ago) parentb7b6ce7
2 files changed+12−25
servant-foreign/servant-foreign.cabal−1 servant-foreign/src/Servant/Foreign/Internal.hs+12−24
servant-foreign/servant-foreign.cabal−1
@@ -55,7 +55,6 @@ library
5555 , GeneralizedNewtypeDeriving
5656 , MultiParamTypeClasses
5757 , ScopedTypeVariables
58− , StandaloneDeriving
5958 , TemplateHaskell
6059 , TypeFamilies
6160 , TypeOperators
servant-foreign/src/Servant/Foreign/Internal.hs+12−24
@@ -1,4 +1,5 @@
11{-# LANGUAGE CPP #-}
2+{-# LANGUAGE DeriveDataTypeable #-}
23#if !MIN_VERSION_base(4,8,0)
34{-# LANGUAGE NullaryTypeClasses #-}
45#endif
@@ -9,6 +10,7 @@ module Servant.Foreign.Internal where
910
1011import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
1112 (.~))
13+import Data.Data
1214#if !MIN_VERSION_base(4,8,0)
1315import Data.Monoid
1416#endif
@@ -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)
2830
2931makePrisms ''FunctionName
3032
3133newtype PathSegment = PathSegment { unPathSegment :: Text }
32− deriving (Show, Eq, IsString, Monoid)
34+ deriving (Data, Show, Eq, IsString, Monoid)
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)
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)
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)
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)
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)
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)
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)
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)
132120
133121makeLenses ''Req
134122