Derive Typeable for internal servant-foreign types

This commit is contained in:
Oleg Grenrus 2017-11-06 12:29:43 +02:00
parent bfe6f5b0a4
commit 80c6ba5347

View File

@ -16,6 +16,7 @@ import Data.Monoid
import Data.Proxy import Data.Proxy
import Data.String import Data.String
import Data.Text import Data.Text
import Data.Typeable (Typeable)
import Data.Text.Encoding (decodeUtf8) import Data.Text.Encoding (decodeUtf8)
import GHC.TypeLits import GHC.TypeLits
import qualified Network.HTTP.Types as HTTP import qualified Network.HTTP.Types as HTTP
@ -25,19 +26,19 @@ import Servant.API.TypeLevel
newtype FunctionName = FunctionName { unFunctionName :: [Text] } newtype FunctionName = FunctionName { unFunctionName :: [Text] }
deriving (Data, Show, Eq, Monoid) deriving (Data, Show, Eq, Monoid, Typeable)
makePrisms ''FunctionName makePrisms ''FunctionName
newtype PathSegment = PathSegment { unPathSegment :: Text } newtype PathSegment = PathSegment { unPathSegment :: Text }
deriving (Data, Show, Eq, IsString, Monoid) deriving (Data, Show, Eq, IsString, Monoid, Typeable)
makePrisms ''PathSegment makePrisms ''PathSegment
data Arg f = Arg data Arg f = Arg
{ _argName :: PathSegment { _argName :: PathSegment
, _argType :: f } , _argType :: f }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makeLenses ''Arg makeLenses ''Arg
@ -49,12 +50,12 @@ data SegmentType f
-- ^ a static path segment. like "/foo" -- ^ a static path segment. like "/foo"
| Cap (Arg f) | Cap (Arg f)
-- ^ a capture. like "/:userid" -- ^ a capture. like "/:userid"
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makePrisms ''SegmentType makePrisms ''SegmentType
newtype Segment f = Segment { unSegment :: SegmentType f } newtype Segment f = Segment { unSegment :: SegmentType f }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makePrisms ''Segment makePrisms ''Segment
@ -72,7 +73,7 @@ data ArgType
= Normal = Normal
| Flag | Flag
| List | List
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makePrisms ''ArgType makePrisms ''ArgType
@ -80,7 +81,7 @@ data QueryArg f = QueryArg
{ _queryArgName :: Arg f { _queryArgName :: Arg f
, _queryArgType :: ArgType , _queryArgType :: ArgType
} }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makeLenses ''QueryArg makeLenses ''QueryArg
@ -90,7 +91,7 @@ data HeaderArg f = HeaderArg
{ _headerArg :: Arg f { _headerArg :: Arg f
, _headerPattern :: Text , _headerPattern :: Text
} }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makeLenses ''HeaderArg makeLenses ''HeaderArg
@ -100,7 +101,7 @@ data Url f = Url
{ _path :: Path f { _path :: Path f
, _queryStr :: [QueryArg f] , _queryStr :: [QueryArg f]
} }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
defUrl :: Url f defUrl :: Url f
defUrl = Url [] [] defUrl = Url [] []
@ -115,7 +116,7 @@ data Req f = Req
, _reqReturnType :: Maybe f , _reqReturnType :: Maybe f
, _reqFuncName :: FunctionName , _reqFuncName :: FunctionName
} }
deriving (Data, Eq, Show) deriving (Data, Eq, Show, Typeable)
makeLenses ''Req makeLenses ''Req