summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphadej <>2019-05-30 10:05:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-05-30 10:05:00 (GMT)
commitd7d26d3817654abadcaf41f73db67fa9c5b6298b (patch)
treea39d695acbf20f8effb3cf166143580789388811
parente5cfbef1f4cec561124469eb94fd1c3c79e3ffa2 (diff)
version 0.16.10.16.1
-rwxr-xr-xCHANGELOG.md10
-rw-r--r--servant.cabal7
-rw-r--r--src/Servant/Types/SourceT.hs32
3 files changed, 46 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 042d6a9..dcb1e40 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
[The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md)
+0.16.1
+------
+
+* Add `Semigroup` and `Monoid` `SourceT` instances
+ [#1158](https://github.com/haskell-servant/servant/pull/1158)
+ [#1159](https://github.com/haskell-servant/servant/pull/1159)
+* Use `http-api-data-0.4.1`
+ [#1181](https://github.com/haskell-servant/servant/pull/1181)
+* Allow newer dependencies
+
0.16.0.1
--------
diff --git a/servant.cabal b/servant.cabal
index ebaafd9..cf88785 100644
--- a/servant.cabal
+++ b/servant.cabal
@@ -1,6 +1,6 @@
cabal-version: >=1.10
name: servant
-version: 0.16.0.1
+version: 0.16.1
synopsis: A family of combinators for defining webservices APIs
category: Servant, Web
@@ -24,7 +24,8 @@ tested-with:
GHC ==8.0.2
|| ==8.2.2
|| ==8.4.4
- || ==8.6.4
+ || ==8.6.5
+ || ==8.8.1
extra-source-files:
CHANGELOG.md
@@ -98,7 +99,7 @@ library
-- We depend (heavily) on the API of these packages:
-- i.e. re-export, or allow using without direct dependency
build-depends:
- http-api-data >= 0.4 && < 0.4.1
+ http-api-data >= 0.4.1 && < 0.4.2
, singleton-bool >= 0.1.4 && < 0.1.5
-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
diff --git a/src/Servant/Types/SourceT.hs b/src/Servant/Types/SourceT.hs
index 284be4b..879313f 100644
--- a/src/Servant/Types/SourceT.hs
+++ b/src/Servant/Types/SourceT.hs
@@ -89,6 +89,21 @@ instance MFunctor SourceT where
hoist f (SourceT m) = SourceT $ \k -> k $
Effect $ f $ fmap (hoist f) $ m return
+-- | >>> source "xy" <> source "z" :: SourceT Identity Char
+-- fromStepT (Effect (Identity (Yield 'x' (Yield 'y' (Yield 'z' Stop)))))
+--
+instance Functor m => Semigroup (SourceT m a) where
+ SourceT withL <> SourceT withR = SourceT $ \ret ->
+ withL $ \l ->
+ withR $ \r ->
+ ret $ l <> r
+
+-- | >>> mempty :: SourceT Maybe Int
+-- fromStepT (Effect (Just Stop))
+instance Functor m => Monoid (SourceT m a) where
+ mempty = fromStepT mempty
+ mappend = (<>)
+
-- | Doesn't generate 'Error' constructors. 'SourceT' doesn't shrink.
instance (QC.Arbitrary a, Monad m) => QC.Arbitrary (SourceT m a) where
arbitrary = fromStepT <$> QC.arbitrary
@@ -150,6 +165,23 @@ instance MFunctor StepT where
go (Yield x s) = Yield x (go s)
go (Effect ms) = Effect (f (fmap go ms))
+instance Functor m => Semigroup (StepT m a) where
+ Stop <> r = r
+ Error err <> _ = Error err
+ Skip s <> r = Skip (s <> r)
+ Yield x s <> r = Yield x (s <> r)
+ Effect ms <> r = Effect ((<> r) <$> ms)
+
+-- | >>> mempty :: StepT [] Int
+-- Stop
+--
+-- >>> mempty :: StepT Identity Int
+-- Stop
+--
+instance Functor m => Monoid (StepT m a) where
+ mempty = Stop
+ mappend = (<>)
+
-- | Doesn't generate 'Error' constructors.
instance (QC.Arbitrary a, Monad m) => QC.Arbitrary (StepT m a) where
arbitrary = QC.sized arb where