From 2054ab9a2d9fe4b3ea3890078a16d85a4d02aa4e Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 25 Dec 2014 03:43:49 +0100 Subject: add TVSearch{,Result} --- Notmuch.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Notmuch.hs') diff --git a/Notmuch.hs b/Notmuch.hs index 7ff6a92..c2c0b34 100644 --- a/Notmuch.hs +++ b/Notmuch.hs @@ -89,15 +89,14 @@ notmuch args = do -- BS.hGetContents hout -search :: String -> IO () -search term = do - c <- notmuch [ "search", "--format=json", "--format-version=2", term ] +search :: String -> IO (Either String [SearchResult]) +search term = + notmuch [ "search", "--format=json", "--format-version=2", term ] + >>= return . eitherDecode' - let results = case eitherDecode' c :: Either String [SearchResult] of - Left err -> error err - Right x -> x - mapM_ (T.putStrLn . drawSearchResult) results +putSearchResults :: [SearchResult] -> IO () +putSearchResults = mapM_ (T.putStrLn . drawSearchResult) showThread :: String -> IO () -- cgit v1.2.3