summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2020-05-01 20:26:45 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-28 16:23:58 -0400
commit5f621a78217237a4bdfb299b68827da6cc8f357e (patch)
treee1418ff44cbb5d4796400df7a12e4f2a8fc43562 /libraries
parent1f393e1e0a2998fe67cfd06501e35f495758b98f (diff)
downloadhaskell-5f621a78217237a4bdfb299b68827da6cc8f357e.tar.gz
Add Semigroup/Monoid for Q (#18123)
Diffstat (limited to 'libraries')
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs9
-rw-r--r--libraries/template-haskell/changelog.md2
2 files changed, 11 insertions, 0 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 60fb9d37ca..d994aa686d 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -33,6 +33,7 @@ import Data.IORef
import System.IO.Unsafe ( unsafePerformIO )
import Control.Monad (liftM)
import Control.Monad.IO.Class (MonadIO (..))
+import Control.Applicative (liftA2)
import System.IO ( hPutStrLn, stderr )
import Data.Char ( isAlpha, isAlphaNum, isUpper, ord )
import Data.Int
@@ -206,6 +207,14 @@ instance Applicative Q where
Q f <*> Q x = Q (f <*> x)
Q m *> Q n = Q (m *> n)
+-- | @since 2.17.0.0
+instance Semigroup a => Semigroup (Q a) where
+ (<>) = liftA2 (<>)
+
+-- | @since 2.17.0.0
+instance Monoid a => Monoid (Q a) where
+ mempty = pure mempty
+
-----------------------------------------------------
--
-- The Quote class
diff --git a/libraries/template-haskell/changelog.md b/libraries/template-haskell/changelog.md
index 55aab10c0d..24a74e4616 100644
--- a/libraries/template-haskell/changelog.md
+++ b/libraries/template-haskell/changelog.md
@@ -22,6 +22,8 @@
* Fix Show instance for `Bytes`: we were showing the pointer value while we
want to show the contents (#16457).
+ * Add `Semigroup` and `Monoid` instances for `Q` (#18123).
+
## 2.16.0.0 *TBA*
* Add support for tuple sections. (#15843) The type signatures of `TupE` and