diff options
author | Johannes Gerer <oss@johannesgerer.com> | 2016-10-26 02:07:02 +0200 |
---|---|---|
committer | Johannes Gerer <oss@johannesgerer.com> | 2016-10-26 02:07:02 +0200 |
commit | 675085c2e0b0b851378da08b7d73024766107c87 (patch) | |
tree | 5a927de4a9576aef7e6129b96e74aa5c96f9ffb6 /src/Benchmarks/BenchmarkUtils.hs | |
download | blazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.gz blazeT-675085c2e0b0b851378da08b7d73024766107c87.tar.zst blazeT-675085c2e0b0b851378da08b7d73024766107c87.zip |
Initial
Diffstat (limited to 'src/Benchmarks/BenchmarkUtils.hs')
-rw-r--r-- | src/Benchmarks/BenchmarkUtils.hs | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/Benchmarks/BenchmarkUtils.hs b/src/Benchmarks/BenchmarkUtils.hs new file mode 100644 index 0000000..4b9546c --- /dev/null +++ b/src/Benchmarks/BenchmarkUtils.hs | |||
@@ -0,0 +1,107 @@ | |||
1 | -- | This is a module which contains some ad-hoc HTML combinators for use when | ||
2 | -- benchmarking | ||
3 | -- | ||
4 | {-# LANGUAGE OverloadedStrings, NoMonomorphismRestriction #-} | ||
5 | module Benchmarks.BenchmarkUtils | ||
6 | ( Html | ||
7 | , toHtml | ||
8 | |||
9 | , tr | ||
10 | , td | ||
11 | , html | ||
12 | , head | ||
13 | , title | ||
14 | , body | ||
15 | , div | ||
16 | , h1 | ||
17 | , h2 | ||
18 | , p | ||
19 | , ol | ||
20 | , li | ||
21 | , table | ||
22 | , img | ||
23 | , id | ||
24 | ) where | ||
25 | |||
26 | import Prelude hiding (div, head, id) | ||
27 | import Text.Blaze | ||
28 | import Text.Blaze.Internal | ||
29 | |||
30 | type Html = Markup | ||
31 | |||
32 | toHtml :: ToMarkup a => a -> Html | ||
33 | toHtml = toMarkup | ||
34 | |||
35 | tr :: Html -- ^ Inner HTML. | ||
36 | -> Html -- ^ Resulting HTML. | ||
37 | tr = Parent "tr" "<tr" "</tr>" | ||
38 | {-# INLINE tr #-} | ||
39 | |||
40 | td :: Html -- ^ Inner HTML. | ||
41 | -> Html -- ^ Resulting HTML. | ||
42 | td = Parent "td" "<td" "</td>" | ||
43 | {-# INLINE td #-} | ||
44 | |||
45 | html :: Html -- ^ Inner HTML. | ||
46 | -> Html -- ^ Resulting HTML. | ||
47 | html = Parent "html" "<html" "</html>" | ||
48 | {-# INLINE html #-} | ||
49 | |||
50 | head :: Html -- ^ Inner HTML. | ||
51 | -> Html -- ^ Resulting HTML. | ||
52 | head = Parent "head" "<head" "</head>" | ||
53 | {-# INLINE head #-} | ||
54 | |||
55 | title :: Html -- ^ Inner HTML. | ||
56 | -> Html -- ^ Resulting HTML. | ||
57 | title = Parent "title" "<title" "</title>" | ||
58 | {-# INLINE title #-} | ||
59 | |||
60 | body :: Html -- ^ Inner HTML. | ||
61 | -> Html -- ^ Resulting HTML. | ||
62 | body = Parent "body" "<body" "</body>" | ||
63 | {-# INLINE body #-} | ||
64 | |||
65 | div :: Html -- ^ Inner HTML. | ||
66 | -> Html -- ^ Resulting HTML. | ||
67 | div = Parent "div" "<div" "</div>" | ||
68 | {-# INLINE div #-} | ||
69 | |||
70 | h1 :: Html -- ^ Inner HTML. | ||
71 | -> Html -- ^ Resulting HTML. | ||
72 | h1 = Parent "h1" "<h1" "</h1>" | ||
73 | {-# INLINE h1 #-} | ||
74 | |||
75 | h2 :: Html -- ^ Inner HTML. | ||
76 | -> Html -- ^ Resulting HTML. | ||
77 | h2 = Parent "h2" "<h2" "</h2>" | ||
78 | {-# INLINE h2 #-} | ||
79 | |||
80 | p :: Html -- ^ Inner HTML. | ||
81 | -> Html -- ^ Resulting HTML. | ||
82 | p = Parent "p" "<p" "</p>" | ||
83 | {-# INLINE p #-} | ||
84 | |||
85 | ol :: Html -- ^ Inner HTML. | ||
86 | -> Html -- ^ Resulting HTML. | ||
87 | ol = Parent "ol" "<ol" "</ol>" | ||
88 | {-# INLINE ol #-} | ||
89 | |||
90 | li :: Html -- ^ Inner HTML. | ||
91 | -> Html -- ^ Resulting HTML. | ||
92 | li = Parent "li" "<li" "</li>" | ||
93 | {-# INLINE li #-} | ||
94 | |||
95 | table :: Html -- ^ Inner HTML. | ||
96 | -> Html -- ^ Resulting HTML. | ||
97 | table = Parent "table" "<table" "</table>" | ||
98 | {-# INLINE table #-} | ||
99 | |||
100 | img :: Html -- ^ Resulting HTML. | ||
101 | img = Leaf "img" "<img" ">" | ||
102 | {-# INLINE img #-} | ||
103 | |||
104 | id :: AttributeValue -- ^ Attribute value. | ||
105 | -> Attribute -- ^ Resulting attribute. | ||
106 | id = attribute "id" " id=\"" | ||
107 | {-# INLINE id #-} | ||