summaryrefslogtreecommitdiffstats
path: root/Notmuch.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Notmuch.hs')
-rw-r--r--Notmuch.hs13
1 files changed, 6 insertions, 7 deletions
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 ()