summaryrefslogtreecommitdiff
path: root/Types/DesktopNotify.hs
blob: ce7e4c4a3e4f1f2283a68cb606d779c82b6c6aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{- git-annex DesktopNotify type
 -
 - Copyright 2014 Joey Hess <id@joeyh.name>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

{-# LANGUAGE CPP #-}

module Types.DesktopNotify where

import Data.Monoid
#if MIN_VERSION_base(4,9,0)
import qualified Data.Semigroup as Sem
#endif
import Prelude

data DesktopNotify = DesktopNotify
	{ notifyStart :: Bool
	, notifyFinish :: Bool
	}
	deriving (Show)

appendDesktopNotify :: DesktopNotify -> DesktopNotify -> DesktopNotify
appendDesktopNotify (DesktopNotify s1 f1) (DesktopNotify s2 f2) =
	DesktopNotify (s1 || s2) (f1 || f2)

#if MIN_VERSION_base(4,9,0)
instance Sem.Semigroup DesktopNotify where
	(<>) = appendDesktopNotify
#endif

instance Monoid DesktopNotify where
	mempty = DesktopNotify False False
#if MIN_VERSION_base(4,11,0)
#elif MIN_VERSION_base(4,9,0)
	mappend = (Sem.<>)
#else
	mappend = appendDesktopNotify
#endif

mkNotifyStart :: DesktopNotify
mkNotifyStart = DesktopNotify True False

mkNotifyFinish :: DesktopNotify
mkNotifyFinish = DesktopNotify False True