git.iko.soy/typeable/html-parse
on master help sign in
More rearranging of export list
0ee3942Ben Gamari
Benchmark.hs+2−2
@@ -11,12 +11,12 @@ main = do
11 [ bgroup "Forced"
11 [ bgroup "Forced"
12 [ bench "tagsoup fast Text" $ nf (Soup.parseTagsOptions Soup.parseOptionsFast) t
12 [ bench "tagsoup fast Text" $ nf (Soup.parseTagsOptions Soup.parseOptionsFast) t
13 , bench "tagsoup normal Text" $ nf (Soup.parseTagsOptions Soup.parseOptions) t
13 , bench "tagsoup normal Text" $ nf (Soup.parseTagsOptions Soup.parseOptions) t
14− , bench "html-parser" $ nf Me.tagStream t
14+ , bench "html-parser" $ nf Me.parseTokens t
15 ]
15 ]
16 , bgroup "length"
16 , bgroup "length"
17 [ bench "tagsoup fast Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptionsFast) t
17 [ bench "tagsoup fast Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptionsFast) t
18 , bench "tagsoup normal Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptions) t
18 , bench "tagsoup normal Text" $ whnf (length . Soup.parseTagsOptions Soup.parseOptions) t
19− , bench "html-parser" $ whnf (length . Me.tagStream) t
19+ , bench "html-parser" $ whnf (length . Me.parseTokens) t
20 ]
20 ]
21 ]
21 ]
22
22
Text/HTML/Parser.hs+8−7
@@ -7,8 +7,8 @@
7--
7--
8module Text.HTML.Parser
8module Text.HTML.Parser
9 ( -- * Parsing
9 ( -- * Parsing
10− token
10+ parseTokens
11− , tagStream
11+ , token
12 -- * Types
12 -- * Types
13 , Token(..)
13 , Token(..)
14 , TagName, AttrName, AttrValue
14 , TagName, AttrName, AttrValue
@@ -41,13 +41,14 @@ type AttrValue = Text
41
41
42-- | An HTML token
42-- | An HTML token
43data Token
43data Token
44− -- | An opening tag. Attribute ordering is arbitrary
44+ -- | An opening tag. Attribute ordering is arbitrary.
45 = TagOpen !TagName [Attr]
45 = TagOpen !TagName [Attr]
46 -- | A closing tag.
46 -- | A closing tag.
47 | TagClose !TagName
47 | TagClose !TagName
48 -- | The content between tags.
48 -- | The content between tags.
49− | ContentChar !Char
50 | ContentText !Text
49 | ContentText !Text
50+ -- | A single character of content
51+ | ContentChar !Char
51 -- | Contents of a comment.
52 -- | Contents of a comment.
52 | Comment !Builder
53 | Comment !Builder
53 -- | Doctype
54 -- | Doctype
@@ -245,9 +246,9 @@ doctype = do
245bogusComment :: Parser Token
246bogusComment :: Parser Token
246bogusComment = fail "Bogus comment"
247bogusComment = fail "Bogus comment"
247
248
248−-- | Produce a lazy list of tokens.
249+-- | Parse a lazy list of tokens.
249−tagStream :: Text -> [Token]
250+parseTokens :: Text -> [Token]
250−tagStream = unfoldr f
251+parseTokens = unfoldr f
251 where
252 where
252 f :: Text -> Maybe (Token, Text)
253 f :: Text -> Maybe (Token, Text)
253 f t
254 f t