summaryrefslogtreecommitdiff
path: root/compiler/utils/PprColour.hs
diff options
context:
space:
mode:
authorKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
committerKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
commit84c2ad99582391005b5e873198b15e9e9eb4f78d (patch)
treecaa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /compiler/utils/PprColour.hs
parent8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff)
parente68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff)
downloadhaskell-wip/T13904.tar.gz
update to current master againwip/T13904
Diffstat (limited to 'compiler/utils/PprColour.hs')
-rw-r--r--compiler/utils/PprColour.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/utils/PprColour.hs b/compiler/utils/PprColour.hs
index ba7435d5c2..f32b8b0084 100644
--- a/compiler/utils/PprColour.hs
+++ b/compiler/utils/PprColour.hs
@@ -1,15 +1,21 @@
module PprColour where
+import GhcPrelude
+
import Data.Maybe (fromMaybe)
import Util (OverridingBool(..), split)
+import Data.Semigroup as Semi
-- | A colour\/style for use with 'coloured'.
newtype PprColour = PprColour { renderColour :: String }
+instance Semi.Semigroup PprColour where
+ PprColour s1 <> PprColour s2 = PprColour (s1 <> s2)
+
-- | Allow colours to be combined (e.g. bold + red);
-- In case of conflict, right side takes precedence.
instance Monoid PprColour where
mempty = PprColour mempty
- PprColour s1 `mappend` PprColour s2 = PprColour (s1 `mappend` s2)
+ mappend = (<>)
renderColourAfresh :: PprColour -> String
renderColourAfresh c = renderColour (colReset `mappend` c)