summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-03-26 21:39:23 -0400
committerJoe Crayne <joe@jerkface.net>2019-03-26 21:39:23 -0400
commit3fe2aaee4abc51de1c4b92909bafdd88be49fd76 (patch)
treea0db519f391ca048db4db9016b3c9ba97893592c
parent29105efba2db42dcce426a29a11539b3083ec356 (diff)
Added Semigroup instance.haskell
-rw-r--r--haskell/Data/VCDIFF.hs3
-rw-r--r--haskell/Data/VCDIFF/Types.hsc3
2 files changed, 6 insertions, 0 deletions
diff --git a/haskell/Data/VCDIFF.hs b/haskell/Data/VCDIFF.hs
index fe4cc98..db75fb1 100644
--- a/haskell/Data/VCDIFF.hs
+++ b/haskell/Data/VCDIFF.hs
@@ -273,6 +273,9 @@ data Result x = Result
273 -- is an error code and message indicating what. 273 -- is an error code and message indicating what.
274 } deriving (Show,Functor) 274 } deriving (Show,Functor)
275 275
276instance Semigroup x => Semigroup (Result x) where
277 Result x xe <> y = Result (x <> result y) (maybe (resultError y) Just xe)
278
276instance Monoid x => Monoid (Result x) where 279instance Monoid x => Monoid (Result x) where
277 mempty = Result mempty Nothing 280 mempty = Result mempty Nothing
278 mappend (Result x xe) y = Result (mappend x $ result y) (maybe (resultError y) Just xe) 281 mappend (Result x xe) y = Result (mappend x $ result y) (maybe (resultError y) Just xe)
diff --git a/haskell/Data/VCDIFF/Types.hsc b/haskell/Data/VCDIFF/Types.hsc
index 015f406..54237b8 100644
--- a/haskell/Data/VCDIFF/Types.hsc
+++ b/haskell/Data/VCDIFF/Types.hsc
@@ -167,6 +167,9 @@ pattern XD3_COMPLEVEL_3 = Flags (#const XD3_COMPLEVEL_3)
167pattern XD3_COMPLEVEL_6 = Flags (#const XD3_COMPLEVEL_6) 167pattern XD3_COMPLEVEL_6 = Flags (#const XD3_COMPLEVEL_6)
168pattern XD3_COMPLEVEL_9 = Flags (#const XD3_COMPLEVEL_9) 168pattern XD3_COMPLEVEL_9 = Flags (#const XD3_COMPLEVEL_9)
169 169
170instance Semigroup Flags where
171 Flags a <> Flags b = Flags (a .|. b)
172
170instance Monoid Flags where 173instance Monoid Flags where
171 mempty = Flags 0 174 mempty = Flags 0
172 Flags a `mappend` Flags b = Flags (a .|. b) 175 Flags a `mappend` Flags b = Flags (a .|. b)