fixed sanitisation a bit
This commit is contained in:
parent
b07950f797
commit
b6f757c35e
4 changed files with 69 additions and 48 deletions
|
|
@ -4,12 +4,29 @@ data TodoListItem = TodoListItem
|
|||
{ name :: String
|
||||
, done :: Bool
|
||||
}
|
||||
deriving (Eq)
|
||||
|
||||
instance Show TodoListItem where
|
||||
show (TodoListItem name done) =
|
||||
s done ++ " " ++ name ++ "\n"
|
||||
where
|
||||
s True = "[x]"
|
||||
s False = "[ ]"
|
||||
s True = "x"
|
||||
s False = "o"
|
||||
showList = foldr ((.) . shows) id
|
||||
|
||||
-- TODO: create a class to render items to html to make it easier to create everything for the website using the web primitives
|
||||
instance Read TodoListItem where
|
||||
readsPrec _ input =
|
||||
let
|
||||
parts = words input
|
||||
in
|
||||
case parts of
|
||||
(status : nameParts) ->
|
||||
let
|
||||
name = unwords nameParts -- Join the remaining parts as the name
|
||||
done = case status of
|
||||
"x" -> True
|
||||
"o" -> False
|
||||
_ -> error "Invalid status"
|
||||
in
|
||||
[(TodoListItem name done, "")]
|
||||
_ -> []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue