Log Analysis Commentary
I've hade some requests to explain some of the less common functions used in my log analysis screencast . I think the most straightforward approach is to examine each of the lines in a literate Haskell style. This is going to be a long-winded description of exactly what's going on. If you understood everything in the screencast, this post will probably bore you. But if you found yourself wondering what the heck was going on, this post might help. > :m + Data.List Data.Function > contents <- readFile "user.log" > let l = lines contents > let t = map words l > mapM print $ take 2 t These four lines are pretty straightforward. ":m +" is GHCi syntax that is similar to an import. readFile :: FilePath -> IO String reads the contents of a file into a string. The lines function splits the string on newlines and creates a list of strings representing each line in the file. We map the words function over each of these lines to split the ...