mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 08:49:40 +03:00
Simplify definition of MaybeDefault
The previous version of MaybeDefault stores pointers to the Eq, Show, and Read instances of the defaulted value. MaybeDefault is used with Style, Color, and Text. All of these types already have all of the necessary instances, and we never work with MaybeDefault generically. Defering the Show, Eq, and Read instances down to the SetTo case isn't helping us to work with types that don't have these instances.
This commit is contained in:
parent
d470f5f9d4
commit
36c1dcc451
@ -1,7 +1,4 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
@ -146,20 +143,14 @@ data FixedAttr = FixedAttr
|
||||
-- | The style and color attributes can either be the terminal defaults.
|
||||
-- Or be equivalent to the previously applied style. Or be a specific
|
||||
-- value.
|
||||
data MaybeDefault v where
|
||||
Default :: MaybeDefault v
|
||||
KeepCurrent :: MaybeDefault v
|
||||
SetTo :: forall v . ( Eq v, Show v, Read v ) => !v -> MaybeDefault v
|
||||
data MaybeDefault v = Default | KeepCurrent | SetTo !v
|
||||
deriving (Eq, Read, Show)
|
||||
|
||||
instance (NFData v) => NFData (MaybeDefault v) where
|
||||
rnf Default = ()
|
||||
rnf KeepCurrent = ()
|
||||
rnf (SetTo v) = rnf v
|
||||
|
||||
deriving instance Eq v => Eq (MaybeDefault v)
|
||||
deriving instance Eq v => Show (MaybeDefault v)
|
||||
deriving instance (Eq v, Show v, Read v) => Read (MaybeDefault v)
|
||||
|
||||
instance Eq v => Semigroup (MaybeDefault v) where
|
||||
Default <> Default = Default
|
||||
Default <> KeepCurrent = Default
|
||||
|
Loading…
Reference in New Issue
Block a user