mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 16:54:42 +03:00
Merge pull request #195 from jtdaugherty/simplify-attr
Simplify definition of MaybeDefault
This commit is contained in:
commit
6fead08444
@ -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