summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdamBergmark <>2019-04-08 05:29:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-04-08 05:29:00 (GMT)
commit298964b5505d4fe2127006c6fb9d61f8e31e6901 (patch)
tree327aed4168f9b3f6ff49371ec10b4636b39c4f18
parent886d1901358381132ed383e8ca1f618597407372 (diff)
version 1.1.0.0HEAD1.1.0.0master
-rw-r--r--CHANGELOG.md4
-rw-r--r--feed.cabal10
-rw-r--r--src/Text/Feed/Import.hs8
-rw-r--r--tests/Text/Atom/Tests.hs2
-rw-r--r--tests/Text/RSS/Tests.hs2
5 files changed, 13 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9166881..cda6d45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.1.0.0
+
+* `parseFeedFromFile` now returns `IO (Maybe Feed)` instead of `IO Feed` to distinguish IO exceptions from parse failures. Thanks to Jake Keuhlen.
+
#### 1.0.1.0
* Support for GHC 8.6.x libraries
diff --git a/feed.cabal b/feed.cabal
index 5233012..c23b908 100644
--- a/feed.cabal
+++ b/feed.cabal
@@ -1,5 +1,5 @@
name: feed
-version: 1.0.1.0
+version: 1.1.0.0
license: BSD3
license-file: LICENSE
category: Text
@@ -29,9 +29,9 @@ tested-with:
, GHC == 7.8.4
, GHC == 7.10.3
, GHC == 8.0.2
- , GHC == 8.2.1
- , GHC == 8.4.1
- , GHC == 8.6.1
+ , GHC == 8.2.2
+ , GHC == 8.4.4
+ , GHC == 8.6.4
data-files:
tests/files/*.xml
extra-source-files:
@@ -136,4 +136,4 @@ test-suite readme
, xml-conduit
, xml-types
build-tool-depends:
- markdown-unlit:markdown-unlit == 0.4.*
+ markdown-unlit:markdown-unlit >= 0.4 && < 0.6
diff --git a/src/Text/Feed/Import.hs b/src/Text/Feed/Import.hs
index 400273a..c7cd0e2 100644
--- a/src/Text/Feed/Import.hs
+++ b/src/Text/Feed/Import.hs
@@ -68,12 +68,8 @@ instance FeedSource String where
-- | 'parseFeedFromFile fp' reads in the contents of the file at @fp@;
-- the assumed encoding is UTF-8.
-parseFeedFromFile :: FilePath -> IO Feed
-parseFeedFromFile fp = do
- ls <- utf8readFile fp
- case parseFeedString ls of
- Nothing -> fail ("parseFeedFromFile: not a well-formed XML content in: " ++ fp)
- Just f -> return f
+parseFeedFromFile :: FilePath -> IO (Maybe Feed)
+parseFeedFromFile fp = parseFeedString <$> utf8readFile fp
-- | 'parseFeedWithParser tries to parse the string @str@
-- as one of the feed formats. First as Atom, then RSS2 before
diff --git a/tests/Text/Atom/Tests.hs b/tests/Text/Atom/Tests.hs
index 4d8a02c..2757bad 100644
--- a/tests/Text/Atom/Tests.hs
+++ b/tests/Text/Atom/Tests.hs
@@ -31,7 +31,7 @@ testFullAtomParse = testCase "parse a complete atom file" testAtom
testAtom :: Assertion
testAtom = do
contents <- parseFeedFromFile =<< getDataFileName "tests/files/atom.xml"
- let res = fmap (renderText def) . elementToDoc . xmlFeed $ contents
+ let res = fmap (renderText def) . (>>= elementToDoc) . fmap xmlFeed $ contents
assertBool "Atom Parsing" $ isJust res
testAtomAlternate :: Test
diff --git a/tests/Text/RSS/Tests.hs b/tests/Text/RSS/Tests.hs
index 3389731..8422636 100644
--- a/tests/Text/RSS/Tests.hs
+++ b/tests/Text/RSS/Tests.hs
@@ -30,5 +30,5 @@ testFullRss20Parse = testCase "parse a complete rss 2.0 file" testRss20
testRss20 :: Assertion
testRss20 = do
contents <- parseFeedFromFile =<< getDataFileName "tests/files/rss20.xml"
- let res = fmap (renderText def) . elementToDoc . xmlFeed $ contents
+ let res = fmap (renderText def) . (>>= elementToDoc) . fmap xmlFeed $ contents
assertBool "RSS 2.0 Parsing" $ isJust res