Skip to content

Instantly share code, notes, and snippets.

@vito
Created December 23, 2008 18:29
Show Gist options
  • Save vito/39412 to your computer and use it in GitHub Desktop.
Save vito/39412 to your computer and use it in GitHub Desktop.
todo.hs $ ghc todo.hs -o todo
todo.o: In function `rJc_info':
(.text+0x189): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_zdf3_closure'
todo.o: In function `sJG_info':
(.text+0x1c5): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_lines_closure'
todo.o: In function `sJN_info':
(.text+0x2b2): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_unlines_closure'
todo.o: In function `sJP_info':
(.text+0x314): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_writeFile_closure'
todo.o: In function `sJB_info':
(.text+0x351): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_readFile_closure'
todo.o: In function `rJe_info':
(.text+0x41d): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_zdf3_closure'
todo.o: In function `sK1_info':
(.text+0x459): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_lines_closure'
todo.o: In function `sKf_info':
(.text+0x4c9): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_drop_closure'
todo.o: In function `sKb_info':
(.text+0x546): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_pack_closure'
todo.o: In function `sKh_info':
(.text+0x59f): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_append_closure'
todo.o: In function `sKn_info':
(.text+0x6c2): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_unlines_closure'
todo.o: In function `sKp_info':
(.text+0x737): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_writeFile_closure'
todo.o: In function `sJW_info':
(.text+0x775): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_readFile_closure'
todo.o: In function `sLq_info':
(.text+0xe5d): undefined reference to `__stginit_bytestringzm0zi9zi1zi4_DataziByteString_'
todo.o: In function `sLq_info':
(.text+0xe67): undefined reference to `__stginit_bytestringzm0zi9zi1zi4_DataziByteStringziChar8_'
todo.o: In function `rJc_srt':
(.data+0x18): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_zdf3_closure'
todo.o: In function `Main_remove_srt':
(.data+0x38): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_readFile_closure'
todo.o: In function `Main_remove_srt':
(.data+0x3c): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_writeFile_closure'
todo.o: In function `Main_remove_srt':
(.data+0x40): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_lines_closure'
todo.o: In function `Main_remove_srt':
(.data+0x44): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_unlines_closure'
todo.o: In function `rJe_srt':
(.data+0x58): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_zdf3_closure'
todo.o: In function `Main_complete_srt':
(.data+0x80): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_append_closure'
todo.o: In function `Main_complete_srt':
(.data+0x84): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_drop_closure'
todo.o: In function `Main_complete_srt':
(.data+0x88): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_readFile_closure'
todo.o: In function `Main_complete_srt':
(.data+0x8c): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteString_writeFile_closure'
todo.o: In function `Main_complete_srt':
(.data+0x90): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_pack_closure'
todo.o: In function `Main_complete_srt':
(.data+0x94): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_lines_closure'
todo.o: In function `Main_complete_srt':
(.data+0x98): undefined reference to `bytestringzm0zi9zi1zi4_DataziByteStringziChar8_unlines_closure'
collect2: ld returned 1 exit status
import System.Environment
import System.IO
import Data.List (delete)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as W
add :: String -> String -> IO ()
add f t = appendFile f ("[ ] " ++ t ++ "\n")
remove :: String -> Int -> IO ()
remove f t = do list <- B.readFile f
let tasks = W.lines list
let newlist = W.unlines $ delete (tasks !! t) tasks
B.writeFile f newlist
complete :: String -> Int -> IO ()
complete f t = do list <- B.readFile f
let tasks = W.lines list
let task = tasks !! t
let newlist = W.unlines $ (delete task tasks) ++ [(W.append (W.pack "[*]") (W.drop 3 task))]
B.writeFile f newlist
main = do args <- getArgs
case args of
[f, "add", task] -> add f task
[f, "complete", task] -> complete f (read task :: Int)
[f, "remove", task] -> remove f (read task :: Int)
_ -> putStrLn "Invalid arguments."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment