From ef48d081dfd0e817c4959dbbd49929ae760a310e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Jan 2015 15:51:57 +0100 Subject: Notmuch: replace {un,}setTag by notmuchTag --- Notmuch/Class.hs | 4 ++++ Notmuch/Message.hs | 4 ++++ Notmuch/SearchResult.hs | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 Notmuch/Class.hs (limited to 'Notmuch') diff --git a/Notmuch/Class.hs b/Notmuch/Class.hs new file mode 100644 index 0000000..2d2b416 --- /dev/null +++ b/Notmuch/Class.hs @@ -0,0 +1,4 @@ +module Notmuch.Class where + +class HasNotmuchId a where + notmuchId :: a -> String diff --git a/Notmuch/Message.hs b/Notmuch/Message.hs index 29ca5ec..dd1e809 100644 --- a/Notmuch/Message.hs +++ b/Notmuch/Message.hs @@ -9,6 +9,7 @@ import Data.Time.Calendar import Data.Time.Clock import Data.Time.Clock.POSIX import Data.Monoid +import Notmuch.Class import qualified Data.Text as T import qualified Data.Map as M import qualified Data.CaseInsensitive as CI @@ -88,6 +89,9 @@ instance Eq Message where a == b = messageId a == messageId b +instance HasNotmuchId Message where + notmuchId = unMessageID . messageId + instance FromJSON Message where parseJSON (Object v) = Message <$> (MessageID . ("id:"<>) <$> v .: "id") diff --git a/Notmuch/SearchResult.hs b/Notmuch/SearchResult.hs index 3a75e96..52b8c20 100644 --- a/Notmuch/SearchResult.hs +++ b/Notmuch/SearchResult.hs @@ -7,6 +7,7 @@ import Data.Aeson import Data.Text import Data.Time.Clock import Data.Time.Clock.POSIX +import Notmuch.Class newtype ThreadID = ThreadID { unThreadID :: String } @@ -33,6 +34,10 @@ instance Eq SearchResult where searchThread s1 == searchThread s2 +instance HasNotmuchId SearchResult where + notmuchId = unThreadID . searchThread + + instance FromJSON SearchResult where parseJSON (Object v) = SearchResult <$> ((ThreadID . ("thread:"++)) <$> v .: "thread") <*> (posixSecondsToUTCTime . fromInteger <$> v .: "timestamp") -- cgit v1.2.3