mirror of
https://github.com/Mesabloo/diagnose.git
synced 2024-11-22 17:52:15 +03:00
Report: add Semigroup and Monoid instances
This commit is contained in:
parent
7578416b72
commit
a5d5c25d8b
@ -42,6 +42,18 @@ data Kind
|
||||
data Hint m
|
||||
= Hint m
|
||||
|
||||
instance Semigroup m => Semigroup (Report m) where
|
||||
Report k1 msg1 markers1 hints1 <> Report k2 msg2 markers2 hints2 =
|
||||
Report detectedKind (msg1 <> msg2) (markers1 <> markers2) (hints1 <> hints2)
|
||||
where
|
||||
detectedKind = case (k1, k2) of
|
||||
(Error, _) -> Error
|
||||
(_, Error) -> Error
|
||||
_ -> Warning
|
||||
|
||||
instance Monoid m => Monoid (Report m) where
|
||||
mempty = reportError mempty mempty mempty
|
||||
|
||||
-- | A polymorphic marker, parameterized on the message type.
|
||||
--
|
||||
-- A marker is either:
|
||||
|
Loading…
Reference in New Issue
Block a user