Merge pull request #846 from phadej/pull-809-foreign-data
Pull 809 foreign data
This commit is contained in:
commit
d04bd290c5
4 changed files with 28 additions and 29 deletions
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
* Add instances for `Description` and `Summary` combinators
|
* Add instances for `Description` and `Summary` combinators
|
||||||
([#767](https://github.com/haskell-servant/servant/pull/767))
|
([#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
|
0.10.1
|
||||||
------
|
------
|
||||||
|
|
|
@ -47,21 +47,21 @@ library
|
||||||
if impl(ghc >= 8.0)
|
if impl(ghc >= 8.0)
|
||||||
ghc-options: -Wno-redundant-constraints
|
ghc-options: -Wno-redundant-constraints
|
||||||
include-dirs: include
|
include-dirs: include
|
||||||
default-extensions: CPP
|
default-extensions: ConstraintKinds
|
||||||
, ConstraintKinds
|
, CPP
|
||||||
, DataKinds
|
, DataKinds
|
||||||
|
, DeriveDataTypeable
|
||||||
, FlexibleContexts
|
, FlexibleContexts
|
||||||
, FlexibleInstances
|
, FlexibleInstances
|
||||||
, GeneralizedNewtypeDeriving
|
, GeneralizedNewtypeDeriving
|
||||||
, MultiParamTypeClasses
|
, MultiParamTypeClasses
|
||||||
|
, OverloadedStrings
|
||||||
|
, PolyKinds
|
||||||
, ScopedTypeVariables
|
, ScopedTypeVariables
|
||||||
, StandaloneDeriving
|
|
||||||
, TemplateHaskell
|
, TemplateHaskell
|
||||||
, TypeFamilies
|
, TypeFamilies
|
||||||
, TypeOperators
|
, TypeOperators
|
||||||
, UndecidableInstances
|
, UndecidableInstances
|
||||||
, OverloadedStrings
|
|
||||||
, PolyKinds
|
|
||||||
|
|
||||||
|
|
||||||
test-suite spec
|
test-suite spec
|
||||||
|
|
|
@ -9,12 +9,14 @@ module Servant.Foreign.Internal where
|
||||||
|
|
||||||
import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
|
import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~),
|
||||||
(.~))
|
(.~))
|
||||||
|
import Data.Data (Data)
|
||||||
#if !MIN_VERSION_base(4,8,0)
|
#if !MIN_VERSION_base(4,8,0)
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
#endif
|
#endif
|
||||||
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
|
||||||
|
@ -24,21 +26,19 @@ import Servant.API.TypeLevel
|
||||||
|
|
||||||
|
|
||||||
newtype FunctionName = FunctionName { unFunctionName :: [Text] }
|
newtype FunctionName = FunctionName { unFunctionName :: [Text] }
|
||||||
deriving (Show, Eq, Monoid)
|
deriving (Data, Show, Eq, Monoid, Typeable)
|
||||||
|
|
||||||
makePrisms ''FunctionName
|
makePrisms ''FunctionName
|
||||||
|
|
||||||
newtype PathSegment = PathSegment { unPathSegment :: Text }
|
newtype PathSegment = PathSegment { unPathSegment :: Text }
|
||||||
deriving (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, Typeable)
|
||||||
deriving instance Eq f => Eq (Arg f)
|
|
||||||
deriving instance Show f => Show (Arg f)
|
|
||||||
|
|
||||||
makeLenses ''Arg
|
makeLenses ''Arg
|
||||||
|
|
||||||
|
@ -50,16 +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, Typeable)
|
||||||
deriving instance Eq f => Eq (SegmentType f)
|
|
||||||
deriving instance Show f => Show (SegmentType f)
|
|
||||||
|
|
||||||
makePrisms ''SegmentType
|
makePrisms ''SegmentType
|
||||||
|
|
||||||
newtype Segment f = Segment { unSegment :: SegmentType f }
|
newtype Segment f = Segment { unSegment :: SegmentType f }
|
||||||
|
deriving (Data, Eq, Show, Typeable)
|
||||||
deriving instance Eq f => Eq (Segment f)
|
|
||||||
deriving instance Show f => Show (Segment f)
|
|
||||||
|
|
||||||
makePrisms ''Segment
|
makePrisms ''Segment
|
||||||
|
|
||||||
|
@ -77,7 +73,7 @@ data ArgType
|
||||||
= Normal
|
= Normal
|
||||||
| Flag
|
| Flag
|
||||||
| List
|
| List
|
||||||
deriving (Eq, Show)
|
deriving (Data, Eq, Show, Typeable)
|
||||||
|
|
||||||
makePrisms ''ArgType
|
makePrisms ''ArgType
|
||||||
|
|
||||||
|
@ -85,9 +81,7 @@ data QueryArg f = QueryArg
|
||||||
{ _queryArgName :: Arg f
|
{ _queryArgName :: Arg f
|
||||||
, _queryArgType :: ArgType
|
, _queryArgType :: ArgType
|
||||||
}
|
}
|
||||||
|
deriving (Data, Eq, Show, Typeable)
|
||||||
deriving instance Eq f => Eq (QueryArg f)
|
|
||||||
deriving instance Show f => Show (QueryArg f)
|
|
||||||
|
|
||||||
makeLenses ''QueryArg
|
makeLenses ''QueryArg
|
||||||
|
|
||||||
|
@ -97,9 +91,7 @@ data HeaderArg f = HeaderArg
|
||||||
{ _headerArg :: Arg f
|
{ _headerArg :: Arg f
|
||||||
, _headerPattern :: Text
|
, _headerPattern :: Text
|
||||||
}
|
}
|
||||||
|
deriving (Data, Eq, Show, Typeable)
|
||||||
deriving instance Eq f => Eq (HeaderArg f)
|
|
||||||
deriving instance Show f => Show (HeaderArg f)
|
|
||||||
|
|
||||||
makeLenses ''HeaderArg
|
makeLenses ''HeaderArg
|
||||||
|
|
||||||
|
@ -109,9 +101,7 @@ data Url f = Url
|
||||||
{ _path :: Path f
|
{ _path :: Path f
|
||||||
, _queryStr :: [QueryArg f]
|
, _queryStr :: [QueryArg f]
|
||||||
}
|
}
|
||||||
|
deriving (Data, Eq, Show, Typeable)
|
||||||
deriving instance Eq f => Eq (Url f)
|
|
||||||
deriving instance Show f => Show (Url f)
|
|
||||||
|
|
||||||
defUrl :: Url f
|
defUrl :: Url f
|
||||||
defUrl = Url [] []
|
defUrl = Url [] []
|
||||||
|
@ -126,9 +116,7 @@ data Req f = Req
|
||||||
, _reqReturnType :: Maybe f
|
, _reqReturnType :: Maybe f
|
||||||
, _reqFuncName :: FunctionName
|
, _reqFuncName :: FunctionName
|
||||||
}
|
}
|
||||||
|
deriving (Data, Eq, Show, Typeable)
|
||||||
deriving instance Eq f => Eq (Req f)
|
|
||||||
deriving instance Show f => Show (Req f)
|
|
||||||
|
|
||||||
makeLenses ''Req
|
makeLenses ''Req
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,15 @@
|
||||||
|
|
||||||
### Other changes
|
### 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
|
- Allow newest dependencies
|
||||||
([#772](https://github.com/haskell-servant/servant/pull/772)
|
([#772](https://github.com/haskell-servant/servant/pull/772)
|
||||||
[#842](https://github.com/haskell-servant/servant/pull/842))
|
[#842](https://github.com/haskell-servant/servant/pull/842))
|
||||||
|
|
Loading…
Reference in a new issue