@@ -1,8 +1,6 @@
1−module Text.XML.DOM.Parser.Common
1+module Text.XML.DOM.Parser.Content
4− -- * Content readers
2+ ( -- * Content readers
7 -- ** Reader constructors
5 -- ** Reader constructors
8 , maybeReadContent
6 , maybeReadContent
@@ -24,9 +22,7 @@ import Control.Lens
24import Control.Monad
22import Control.Monad
25import Control.Monad.Except
23import Control.Monad.Except
26import Data.List as L
24import Data.List as L
27−import Data.List.NonEmpty as NE
28import Data.Map.Strict as M
25import Data.Map.Strict as M
30import Data.Monoid
26import Data.Monoid
31import Data.Text as T
27import Data.Text as T
32import Data.Typeable
28import Data.Typeable
@@ -34,25 +30,6 @@ import Text.Read
34import Text.XML.DOM.Parser.Types
30import Text.XML.DOM.Parser.Types
35import Text.XML.Lens
31import Text.XML.Lens
37−-- | Class of traversable functors which may be constructed from list. Or may
39−class Traversable f => Buildable f where
40− -- | If method return Nothing this means we can not build
41− -- traversable from given list. In this case 'inFilteredTrav' should
43− build :: [a] -> Maybe (f a)
45−instance Buildable Identity where
46− build = fmap Identity . listToMaybe
48−instance Buildable [] where
51−instance Buildable Maybe where
52− build = Just . listToMaybe
54−instance Buildable NonEmpty where
57-- | @since 1.0.0
34-- | @since 1.0.0
58readBool :: Text -> Either Text Bool
35readBool :: Text -> Either Text Bool
@@ -76,7 +53,8 @@ readChar t = case T.unpack $ T.strip t of
76 _ -> Left "Should have exactly one non-blank character"
53 _ -> Left "Should have exactly one non-blank character"
78-- | If reader returns 'Nothing' then resulting function returns 'Left
55-- | If reader returns 'Nothing' then resulting function returns 'Left
79−-- "error message"'
56+-- "error message"'. 'Typeable' is used for generating usefull error
81-- @since 1.0.0
59-- @since 1.0.0
82maybeReadContent
60maybeReadContent
@@ -94,7 +72,8 @@ maybeReadContent f t = maybe (Left msg) Right $ f t
96-- | Tries to read given text to value using 'Read'. Useful to use
74-- | Tries to read given text to value using 'Read'. Useful to use
97−-- with 'parseContent' and 'parseAttribute'
75+-- with 'parseContent' and 'parseAttribute'. Content is stripped
98readContent
77readContent
99 :: (Read a, Typeable a)
78 :: (Read a, Typeable a)
@@ -186,7 +165,8 @@ parseAttribute attrName parser =
186 Nothing -> throwParserError $ PEAttributeNotFound attrName
165 Nothing -> throwParserError $ PEAttributeNotFound attrName
187 Just a -> return a
166 Just a -> return a
189−-- | Parses attribute with given name.
168+-- | Parses attribute with given name. Returns Nothing if attribute is
191-- @since 1.0.0
171-- @since 1.0.0
192parseAttributeMaybe
172parseAttributeMaybe