--- /dev/null
+{-# OPTIONS_GHC -Wall #-}
+module LogAnalysis where
+
+import Log
+
+parseMessage :: String -> LogMessage
+parseMessage s = let ws = words s in
+ parseMessage' ws
+ where
+ parseMessage' ("I":ts:ws') = LogMessage Info (read ts) (unwords ws')
+ parseMessage' ("W":ts:ws') = LogMessage Warning (read ts) (unwords ws')
+ parseMessage' ("E":level:ts:ws') = LogMessage (Error (read level)) (read ts) (unwords ws')
+ parseMessage' x = Unknown (unwords x)
+
+parse :: String -> [LogMessage]
+parse s = map parseMessage (lines s)
+
+