on master help sign in
Merge pull request #195 from jtdaugherty/simplify-attr
6fead08Jonathan Daugherty
src/Graphics/Vty/Attributes.hs+2−11
@@ -1,7 +1,4 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE StandaloneDeriving #-}
3−{-# LANGUAGE GADTs #-}
4−{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
6{-# LANGUAGE DeriveAnyClass #-}
3{-# LANGUAGE DeriveAnyClass #-}
7
4
@@ -146,20 +143,14 @@ data FixedAttr = FixedAttr
146-- | The style and color attributes can either be the terminal defaults.
143-- | The style and color attributes can either be the terminal defaults.
147-- Or be equivalent to the previously applied style. Or be a specific
144-- Or be equivalent to the previously applied style. Or be a specific
148-- value.
145-- value.
149−data MaybeDefault v where
146+data MaybeDefault v = Default | KeepCurrent | SetTo !v
150− Default :: MaybeDefault v
147+ deriving (Eq, Read, Show)
151− KeepCurrent :: MaybeDefault v
152− SetTo :: forall v . ( Eq v, Show v, Read v ) => !v -> MaybeDefault v
153
148
154instance (NFData v) => NFData (MaybeDefault v) where
149instance (NFData v) => NFData (MaybeDefault v) where
155 rnf Default = ()
150 rnf Default = ()
156 rnf KeepCurrent = ()
151 rnf KeepCurrent = ()
157 rnf (SetTo v) = rnf v
152 rnf (SetTo v) = rnf v
158
153
159−deriving instance Eq v => Eq (MaybeDefault v)
160−deriving instance Eq v => Show (MaybeDefault v)
161−deriving instance (Eq v, Show v, Read v) => Read (MaybeDefault v)
162−
163instance Eq v => Semigroup (MaybeDefault v) where
154instance Eq v => Semigroup (MaybeDefault v) where
164 Default <> Default = Default
155 Default <> Default = Default
165 Default <> KeepCurrent = Default
156 Default <> KeepCurrent = Default