aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/NoPersist.hs
blob: 66e52da748d1c8ca7c16c76913740059dfeaed38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Module for not persisting XMonad state. To be used with ExtensibleState
-- for data types that cannot be persisted.
module Rahm.Desktop.NoPersist where

import Data.Default (Default, def)
import Data.Typeable

import XMonad (ExtensionClass(..))

newtype NoPersist a = NoPersist a
  deriving (Typeable)

instance Show (NoPersist a) where
  show (NoPersist _) = show ()

instance (Default a) => Read (NoPersist a) where
  readsPrec i s = map (\(_, s) -> (NoPersist def, s)) (readsPrec i s :: [((), String)])

instance (Default a) => Default (NoPersist a) where
  def = NoPersist def

instance (Default a, Typeable a) => ExtensionClass (NoPersist a) where
  initialValue = NoPersist def