From 936f769f8b1b3a80de9848081cb56ffc6873ea7e Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Mon, 15 Dec 2014 21:37:12 +0530
Subject: [PATCH] hw #2 solution. WIP

---
 hw2/LogAnalysis.hs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 hw2/LogAnalysis.hs

diff --git a/hw2/LogAnalysis.hs b/hw2/LogAnalysis.hs
new file mode 100644
index 0000000..dc393b2
--- /dev/null
+++ b/hw2/LogAnalysis.hs
@@ -0,0 +1,18 @@
+{-# 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)
+
+
-- 
2.45.2