diff options
author | koral <> | 2020-08-01 14:07:00 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2020-08-01 14:07:00 (GMT) |
commit | d7503e53e6e210bc4aec732049a9eaa112fe8132 (patch) | |
tree | 4475f5bf06dd44cda318cd22b0e8efec13b9e131 | |
parent | 13e2a350a8d7b35d80ad2b7da46ea142b8211c7f (diff) |
-rw-r--r-- | Text/OPML/Types.hs | 4 | ||||
-rw-r--r-- | opml-conduit.cabal | 6 | ||||
-rw-r--r-- | test/Arbitrary.hs | 11 |
3 files changed, 9 insertions, 12 deletions
diff --git a/Text/OPML/Types.hs b/Text/OPML/Types.hs index 3bf821c..b4f222e 100644 --- a/Text/OPML/Types.hs +++ b/Text/OPML/Types.hs @@ -54,7 +54,9 @@ import URI.ByteString data Null deriving(Typeable) instance Predicate Null Text where - validate p value = unless (Text.null value) $ throwRefine $ RefineOtherException (typeOf p) "Text is not null" + validate p value = if not $ Text.null value + then pure $ RefineOtherException (typeOf p) "Text is not null" + else Nothing data OpmlHead = OpmlHead { opmlTitle :: Text diff --git a/opml-conduit.cabal b/opml-conduit.cabal index f57dfc4..257c394 100644 --- a/opml-conduit.cabal +++ b/opml-conduit.cabal @@ -1,5 +1,5 @@ name: opml-conduit -version: 0.8.0.0 +version: 0.9.0.0 synopsis: Streaming parser/renderer for the OPML 2.0 format. description: This library implements the OPML 2.0 standard (<http://dev.opml.org/spec2.html>) as a 'conduit' parser/renderer. @@ -46,7 +46,7 @@ library , microlens , microlens-th , monoid-subclasses - , refined >= 0.2 + , refined >= 0.5 , semigroups , text , time >= 1.5 @@ -77,7 +77,7 @@ test-suite tests , parsers , QuickCheck , quickcheck-instances - , refined >= 0.2 + , refined >= 0.5 , resourcet , semigroups , tasty diff --git a/test/Arbitrary.hs b/test/Arbitrary.hs index 6660c0c..4568115 100644 --- a/test/Arbitrary.hs +++ b/test/Arbitrary.hs @@ -14,7 +14,7 @@ import Data.ByteString (ByteString) import Data.Char import Data.List.NonEmpty import Data.Maybe -import Data.Text as Text (Text, find, null, pack) +import Data.Text as Text (Text, find, pack) import Data.Text.Encoding import Data.Time.Clock import Data.Tree @@ -95,11 +95,6 @@ genCategoryPath = (:|) <$> genCategory <*> listOf genCategory where genAlphaNum :: Gen Char genAlphaNum = oneof [choose('a', 'z'), suchThat arbitrary isDigit] -instance Arbitrary (Refined (Not Null) Text) where - arbitrary = do - ~(Right t) <- refine <$> arbitrary `suchThat` (not . Text.null) - return t - instance Arbitrary OpmlHead where arbitrary = OpmlHead <$> arbitrary @@ -160,6 +155,6 @@ genOutlineTree n = do root <- arbitrary degree <- choose (0, 100) case (n > 1, root) of - (True, OpmlOutlineGeneric _ _) -> Node <$> pure root <*> vectorOf degree (genOutlineTree (n-1)) + (True, OpmlOutlineGeneric _ _) -> Node <$> pure root <*> vectorOf degree (genOutlineTree (n-1)) (False, OpmlOutlineGeneric _ _) -> return $ Node root [] - _ -> return $ Node root [] + _ -> return $ Node root [] |