@@ -1,3 +1,4 @@
1{-# LANGUAGE StandaloneDeriving #-}
2{-# LANGUAGE StandaloneDeriving #-}
2{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GADTs #-}
3{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE RankNTypes #-}
@@ -60,6 +61,9 @@ module Graphics.Vty.Attributes
62import Data.Bits
63import Data.Bits
64+#if !(MIN_VERSION_base(4,11,0))
63import Data.Text (Text)
67import Data.Text (Text)
64import Data.Word
68import Data.Word
@@ -111,13 +115,18 @@ data Attr = Attr
111-- Then the foreground color encoded into 8 bits.
115-- Then the foreground color encoded into 8 bits.
112-- Then the background color encoded into 8 bits.
116-- Then the background color encoded into 8 bits.
118+instance Semigroup Attr where
120+ Attr ( attrStyle attr0 <> attrStyle attr1 )
121+ ( attrForeColor attr0 <> attrForeColor attr1 )
122+ ( attrBackColor attr0 <> attrBackColor attr1 )
123+ ( attrURL attr0 <> attrURL attr1 )
114instance Monoid Attr where
125instance Monoid Attr where
115 mempty = Attr mempty mempty mempty mempty
126 mempty = Attr mempty mempty mempty mempty
127+#if !(MIN_VERSION_base(4,11,0))
116− mappend attr0 attr1 =
128+ mappend = (<>)
117− Attr ( attrStyle attr0 `mappend` attrStyle attr1 )
129+#endif
118− ( attrForeColor attr0 `mappend` attrForeColor attr1 )
119− ( attrBackColor attr0 `mappend` attrBackColor attr1 )
120− ( attrURL attr0 `mappend` attrURL attr1 )
122-- | Specifies the display attributes such that the final style and
131-- | Specifies the display attributes such that the final style and
123-- color values do not depend on the previously applied display
132-- color values do not depend on the previously applied display
@@ -142,17 +151,22 @@ deriving instance Eq v => Eq (MaybeDefault v)
142deriving instance Eq v => Show (MaybeDefault v)
151deriving instance Eq v => Show (MaybeDefault v)
143deriving instance (Eq v, Show v, Read v) => Read (MaybeDefault v)
152deriving instance (Eq v, Show v, Read v) => Read (MaybeDefault v)
154+instance Eq v => Semigroup (MaybeDefault v) where
155+ Default <> Default = Default
156+ Default <> KeepCurrent = Default
157+ Default <> SetTo v = SetTo v
158+ KeepCurrent <> Default = Default
159+ KeepCurrent <> KeepCurrent = KeepCurrent
160+ KeepCurrent <> SetTo v = SetTo v
161+ SetTo _v <> Default = Default
162+ SetTo v <> KeepCurrent = SetTo v
163+ SetTo _ <> SetTo v = SetTo v
145instance Eq v => Monoid ( MaybeDefault v ) where
165instance Eq v => Monoid ( MaybeDefault v ) where
146 mempty = KeepCurrent
166 mempty = KeepCurrent
147− mappend Default Default = Default
167+#if !(MIN_VERSION_base(4,11,0))
148− mappend Default KeepCurrent = Default
149− mappend Default ( SetTo v ) = SetTo v
150− mappend KeepCurrent Default = Default
151− mappend KeepCurrent KeepCurrent = KeepCurrent
152− mappend KeepCurrent ( SetTo v ) = SetTo v
153− mappend ( SetTo _v ) Default = Default
168+ mappend = (<>)
154− mappend ( SetTo v ) KeepCurrent = SetTo v
169+#endif
155− mappend ( SetTo _ ) ( SetTo v ) = SetTo v
157-- | Styles are represented as an 8 bit word. Each bit in the word is 1
171-- | Styles are represented as an 8 bit word. Each bit in the word is 1
158-- if the style attribute assigned to that bit should be applied and 0
172-- if the style attribute assigned to that bit should be applied and 0