Repository navigation
Expand file tree
/
Copy pathhtmlGenerator.hs
More file actions
209 lines (126 loc) · 3.8 KB
/
Copy pathhtmlGenerator.hs
File metadata and controls
209 lines (126 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
-- Try to make an emmet vim in haskell
-- which syntax is better?
surround xs byY andZ = byY ++ xs ++ andZ
surroundbyYandZ xs y z = y ++ xs ++ z
surroundbyYandZ "asdj" "div" "vid"
tags xs = '<' : xs ++ ['>']
tags "div"
tags2 xs b a = b ++ xs ++ a
endTags xs = "</" ++ xs ++ ['>']
endTags "div"
t x = tags2 x "<" ">\n"
et x = tags2 x "</" ">"
putStrLn $ tags2 "asjfjksd" "<" ">\n"
putStrLn $ elementize "div" "randomtext\n"
elementize "div" "randomtext"
putStrLn $ elementize "ul" $ elementize "div" "randomtext"
putStrLn $ elementize "div" "randomtext"
putStrLn $ addTab (elementize "div" "randomtext") '\n'
putStrLn $ elementize "li" $ elementize "div" "randomtext"
putStrLn $ elementize "li" $ addTab (elementize "div" "randomtext") '\n'
putStrLn $
-- there's a fundamental problem with how these are defined
putStrLn $ addTab (elementize "li" $ addTab (elementize "div" "randomtext") '\n') '\n'
putStrLn $ addTab (elementize "li" $ (elementize "div" " randomtext")) '\n'
-- its like some kind of twisted dependency. can't tab the second line without tabbing the last line
-- try this
realTab x = addTab (tab x) '\n'
putStrLn $ elementize "li" $ realTab $ elementize "div" $ realTab "asdf"
a
let a = nestedElements ["img","div","div"] "text"
let b = map (nestedElements ["div"]) ["text","free"]
-- cool, this is how you parallelize it
mapM (nestedElements ["div"]) ["text","free"]
:t mapM (nestedElements ["div"]) ["text","free"]
nestedElements ["div"] "text"
nestedElements ["div"] "text"
nestedElements ["html"] (nestedElements ["div"] "text")
:t mapM
:t nestedElements ["div"]
:t nestedElements
mapIO (nestedElements ["div"]) ["text","free"]
mapIO nestedElements ["div"] ["text","free"]
-- not right, needs some correction
-- need to get rid of the extra space at the end
putStrLn $ foldl (\x y -> x ++ "\n" ++ y) "" $ map (nestedElements2 ["div"]) ["text","free","point"]
map (nestedElements2 ["div"]) ["text","free"]
:t nestedElements
:{
mapIO :: (a -> IO b) -> [a] -> [b] -> IO [b]
mapIO f [] acc = do return acc
mapIO f (x:xs) acc = do
new <- f x
mapIO f xs (new:acc)
:}
-- correct
-- now its composable
nestedElements2 ["bjsdjf"] $ nestedElements2 ["akd"] "text"
:{
let nestedElements2 [] y = y
nestedElements2 (x:xs) y = nestedElements2 xs er
where er = elementize x $ realTab y
:}
-- correct
:{
let nestedElements [] y = putStrLn y
nestedElements (x:xs) y = nestedElements xs er
where er = elementize x $ realTab y
:}
:t realTab
:{
elementize tagname content = surround tabbedct tag endtag
where tag = t tagname
endtag = et tagname
tabbedct = content ++ "\n"
:}
-- i think this is the one used in the above defn
-- the second char should be \n to get realtab above
:{
let addTab [] _ = []
addTab (x:xs) z
| x == z = z : " " ++ addTab xs z
| otherwise = x : addTab xs z
:}
:t addTab
tab x = " " ++ x
addTab "anb\najsdfj"
addTab "anbbsdjfjbbajsdfj" "bb"
doubleCat "anbbsdjfjbbajsdfj"
doubleCat "anb\nbsdjfjbbajsdfj"
-- ah the \n is a char, not a string!
addTab "anb\nbsdjfjbbajsdfj" '\n'
map (\x -> x:[x]) [1..5]
mm f (x:xs) = f x :
doubleCat [1..5]
:{
doubleCat [] = []
doubleCat (x:xs) = x:x: doubleCat xs
:}
flatten
double x = x:x
addTab
:{
let addTab [x] _ = [x]
addTab (x:y:xs) z
| [x,y] == z = z ++ " " ++ addTab xs z
| otherwise = x : addTab (y:xs) z
:}
:{
let addTab [x] = [x]
addTab (x:y:xs)
| [x,y] == "\n" = "\n " ++ addTab xs
| otherwise = x : addTab (y:xs)
:}
'b'
'\\'
['\','n']
:{
elementize tagname content = surround content tag endtag
where tag = tags tagname
endtag = endTags tagname
:}
elementize "ul" $ elementize "div" "randomtext"
elementize "ul" $ elementize "div" "randomtext"
:t putStrLn
putStrLn $ "foo" ++ "\n" ++ "bar"
map (elementize "li") ["List1","List2","List3"]