-- | Some semigroup instances used in several places

module Agda.Utils.Semigroup (
  module Data.Semigroup)
where

import Data.Semigroup ( Semigroup, (<>) )

import Control.Applicative (liftA2)

import Control.Monad.Reader (ReaderT)
import Control.Monad.State  (StateT)

instance (Applicative m, Semigroup doc) => Semigroup (ReaderT s m doc) where
  {-# INLINE (<>) #-}
  <> :: ReaderT s m doc -> ReaderT s m doc -> ReaderT s m doc
(<>) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Semigroup a => a -> a -> a
(<>)

instance (Monad m, Semigroup doc)       => Semigroup (StateT s m doc)  where
  {-# INLINE (<>) #-}
  <> :: StateT s m doc -> StateT s m doc -> StateT s m doc
(<>) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Semigroup a => a -> a -> a
(<>)