Skip to content

Commit 155de37

Browse files
committed
okay should be ready
1 parent be65e1f commit 155de37

File tree

4 files changed

+109
-10
lines changed

4 files changed

+109
-10
lines changed

quack.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Library
1919
, attoparsec
2020
, aeson
2121
, text
22+
, http-types
2223

2324
Source-Repository head
2425
Type: git

src/Data/Uri/Quack.hs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Data.Uri.Quack
77
( Parser
88
, runParser
9+
, decodeUtf8Query
910
, ParserError (..)
1011
, -- * Combining
1112
unlabeled
@@ -21,15 +22,18 @@ module Data.Uri.Quack
2122
import qualified Data.Attoparsec.Text as Atto (Parser, parseOnly)
2223
import qualified Data.Aeson as Aeson (FromJSON, eitherDecode)
2324

24-
import Data.Text as T
25-
import Data.Text.Lazy as LT
26-
import Data.Text.Lazy.Encoding as LT
25+
import qualified Data.Text as T
26+
import qualified Data.Text.Encoding as T
27+
import qualified Data.Text.Lazy as LT
28+
import qualified Data.Text.Lazy.Encoding as LT
2729
import Data.Functor.Identity
2830
import Data.String (IsString (fromString))
2931
import Control.Applicative
3032
import Control.Monad.State
3133
import Control.Monad.Except
3234

35+
import Network.HTTP.Types.URI (Query)
36+
3337

3438

3539
data ParserState = ParserState
@@ -43,6 +47,10 @@ initParserState xs = ParserState
4347
}
4448

4549

50+
decodeUtf8Query :: Query -> [(T.Text, Maybe T.Text)]
51+
decodeUtf8Query = map (\(l,r) -> (T.decodeUtf8 l, T.decodeUtf8 <$> r))
52+
53+
4654
data ParserError
4755
= NoParse String
4856
deriving (Show, Eq)
@@ -96,11 +104,15 @@ instance Alternative Parser where
96104
pure []
97105

98106
-- | Parse /only/ the label, disregarding any @=@ value;
99-
-- .
107+
--
100108
-- > unlabeled (attoparsec double)
101-
-- . would parse something like
109+
--
110+
-- would parse something like
111+
--
102112
-- > "/foo?1234"
103-
-- . /or/
113+
--
114+
-- /or/
115+
--
104116
-- > "/foo?1234=asdf"
105117
unlabeled :: PieceParser a -> Parser a
106118
unlabeled (PieceParser f) = Parser $ do
@@ -118,9 +130,11 @@ unlabeled (PieceParser f) = Parser $ do
118130

119131
-- | Parse with a label, but throw the parse result of the
120132
-- label away;
121-
-- .
133+
--
122134
-- > "foo" .= attoparsec double
123-
-- . would parse something like
135+
--
136+
-- would parse something like
137+
--
124138
-- > "/foo?foo=1234"
125139
(.=) :: PieceParser a -> PieceParser b -> Parser b
126140
(PieceParser l) .= (PieceParser f) = Parser $ do
@@ -143,10 +157,12 @@ unlabeled (PieceParser f) = Parser $ do
143157

144158

145159
-- | @liftM2@ for parse results /between/ @=@, for instance:
146-
-- .
160+
--
147161
-- > overEquals (,) (attoparsec $ double <* endOfInput)
148162
-- > (attoparsec $ double <* endOfInput)
149-
-- . would parse something like
163+
--
164+
-- would parse something like
165+
--
150166
-- > "/foo?1234=1234"
151167
overEquals :: (a -> b -> c) -> PieceParser a -> PieceParser b -> Parser c
152168
overEquals f (PieceParser l) (PieceParser r) = Parser $ do

src/highlight.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
var highlight = function (on) {
3+
return function () {
4+
var links = document.getElementsByTagName('a');
5+
for (var i = 0; i < links.length; i++) {
6+
var that = links[i];
7+
8+
if (this.href != that.href) {
9+
continue;
10+
}
11+
12+
if (on) {
13+
that.classList.add("hover-highlight");
14+
} else {
15+
that.classList.remove("hover-highlight");
16+
}
17+
}
18+
}
19+
};
20+
21+
window.onload = function () {
22+
var links = document.getElementsByTagName('a');
23+
for (var i = 0; i < links.length; i++) {
24+
links[i].onmouseover = highlight(true);
25+
links[i].onmouseout = highlight(false);
26+
}
27+
};

src/style.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
body {
2+
background-color: #fdf6e3;
3+
}
4+
5+
.hs-identifier {
6+
color: #073642;
7+
}
8+
9+
.hs-identifier.hs-var {
10+
}
11+
12+
.hs-identifier.hs-type {
13+
color: #5f5faf;
14+
}
15+
16+
.hs-keyword {
17+
color: #af005f;
18+
}
19+
20+
.hs-string, .hs-char {
21+
color: #cb4b16;
22+
}
23+
24+
.hs-number {
25+
color: #268bd2;
26+
}
27+
28+
.hs-operator {
29+
color: #d33682;
30+
}
31+
32+
.hs-glyph, .hs-special {
33+
color: #dc322f;
34+
}
35+
36+
.hs-comment {
37+
color: #8a8a8a;
38+
}
39+
40+
.hs-pragma {
41+
color: #2aa198;
42+
}
43+
44+
.hs-cpp {
45+
color: #859900;
46+
}
47+
48+
a:link, a:visited {
49+
text-decoration: none;
50+
border-bottom: 1px solid #eee8d5;
51+
}
52+
53+
a:hover, a.hover-highlight {
54+
background-color: #eee8d5;
55+
}

0 commit comments

Comments
 (0)