readme + refactor
This commit is contained in:
parent
b6f757c35e
commit
045908d7c3
5 changed files with 72 additions and 93 deletions
|
|
@ -15,18 +15,15 @@ instance Show TodoListItem where
|
|||
showList = foldr ((.) . shows) id
|
||||
|
||||
instance Read TodoListItem where
|
||||
readsPrec _ input =
|
||||
readsPrec _ input = do
|
||||
let (item, rest) = break (== '\n') input
|
||||
let (d, n) = splitAt 2 item
|
||||
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, "")]
|
||||
_ -> []
|
||||
done = case d of
|
||||
"x " -> True
|
||||
"o " -> False
|
||||
_ -> error "Invalid status"
|
||||
name = case n of
|
||||
"" -> error "empty name"
|
||||
something -> filter (/= '\r') something
|
||||
[(TodoListItem name done, rest)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue