Commit bd71771e authored by Oscar Leijendekker's avatar Oscar Leijendekker

Added code for ch.4

parent d61c91fa
Pipeline #90554021 passed with stage
in 4 minutes and 4 seconds
......@@ -19,3 +19,38 @@ requestHandler request respond =
do
putStrLn "Received an HTTP request!"
respond response
data TaskStatus = Done | NotDone
data Task = Task String TaskStatus
myTask :: Task
myTask = Task "create todo list" NotDone
myTodoList :: [Task]
myTodoList =
[ Task "create todo list" Done
, Task "invent terror drones" NotDone
, Task "achieve world domination" NotDone
]
toHTML :: Task -> String
toHTML task =
case task of
Task description status ->
case status of
NotDone -> "<p>" ++ description ++ "</p>"
Done -> "<p><strike>" ++ description ++ "</strike></p>"
toHTMLPage :: String -> String
toHTMLPage innerHTML =
"<!DOCTYPE html>\
\<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\
\<head>\
\ <meta charset=\"utf-8\" />\
\ <title>TODO list </title>\
\</head>\
\<body>\
\ " ++ innerHTML ++
"</body>"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment