summaryrefslogtreecommitdiff
path: root/src/Data/CxMonoid.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/CxMonoid.hs')
-rw-r--r--src/Data/CxMonoid.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Data/CxMonoid.hs b/src/Data/CxMonoid.hs
index 8758449..ef517f1 100644
--- a/src/Data/CxMonoid.hs
+++ b/src/Data/CxMonoid.hs
@@ -16,6 +16,7 @@
module Data.CxMonoid (MonoidDict, CxMonoid(..), biCxMonoid) where
import Data.Monoid (Monoid(..))
+import qualified Data.Semigroup as Sem
import Data.Bijection
import Data.Title
@@ -30,10 +31,13 @@ newtype CxMonoid a = CxMonoid { unCxMonoid :: MonoidDict a -> a }
biCxMonoid :: (MonoidDict a -> a) :<->: CxMonoid a
biCxMonoid = Bi CxMonoid unCxMonoid
+instance Sem.Semigroup (CxMonoid a) where
+ CxMonoid f <> CxMonoid g =
+ CxMonoid (\ md@(_,op) -> f md `op` g md)
+
instance Monoid (CxMonoid a) where
mempty = CxMonoid (\ (e,_) -> e)
- CxMonoid f `mappend` CxMonoid g =
- CxMonoid (\ md@(_,op) -> f md `op` g md)
+ mappend = (Sem.<>)
-- Exploit the function instance of 'Title'
instance Title a => Title (CxMonoid a) where