From c4698230179be17f66dc17339cef379733b89fd1 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 14 Jul 2014 10:27:01 -0400 Subject: [PATCH] Bump version to 0.1.0. Use <$> instead of fmap in a few places. Report non-integer XML File IDs as info instead of errors. --- htsn.cabal | 2 +- src/Main.hs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htsn.cabal b/htsn.cabal index 1a27245..a494090 100644 --- a/htsn.cabal +++ b/htsn.cabal @@ -1,5 +1,5 @@ name: htsn -version: 0.0.11 +version: 0.1.0 cabal-version: >= 1.8 author: Michael Orlitzky maintainer: Michael Orlitzky diff --git a/src/Main.hs b/src/Main.hs index aebf5c5..de0e28e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -5,6 +5,7 @@ module Main where -- System imports. +import Control.Applicative ( (<$>) ) import Control.Concurrent ( threadDelay ) import Control.Exception ( bracket, throw ) import Control.Monad ( when ) @@ -71,12 +72,17 @@ recv_line h = do -- This can fail, but we don't purposefully throw any exceptions. If -- something goes wrong, we would rather log it and keep going. -- +-- And in fact the only \"error\" that can occur is from +-- 'parse_xmlfid' if TSN sends us a non-integer XML File ID. But +-- this is expected from time to time, and is merely unsupported. So +-- we report any failures as info instead of as errors. +-- save_document :: Configuration -> String -- ^ String representation of an XML document -> IO () save_document cfg doc = case either_path of - Left err -> report_error err + Left err -> report_info err -- Can only be non-integer XML File ID Right path -> do already_exists <- doesFileExist path when already_exists $ do @@ -85,10 +91,10 @@ save_document cfg doc = writeFile path doc report_info $ "Wrote file: " ++ path ++ "." where - -- All the fmaps are because we're working inside a Maybe. - xmlfid = fmap show (parse_xmlfid doc) - filename = fmap (++ ".xml") xmlfid - either_path = fmap ((output_directory cfg) ) filename + -- All the <$> are because we're working inside an Either. + xmlfid = show <$> (parse_xmlfid doc) + filename = (++ ".xml") <$> xmlfid + either_path = ((output_directory cfg) ) <$> filename -- | Loop forever, writing the @buffer@ to file whenever a -- 2.44.2