<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 24 February 2015 at 13:22, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Thanks,<br>
<br>
I rewrote it like this :<br>
<br>
parseMessage :: String -> LogMessage<br>
parseMessage s =<br>
  Â case words s of<br>
  Â  Â  Â  ("I":time:text)  Â  Â  Â  Â  Â -> LogMessage Info (read time) (unwords text)<br>
  Â  Â  Â  ("W":time:text)  Â  Â  Â  Â  Â -> LogMessage Warning (read time) (unwords text)<br>
  Â  Â  Â  ("E":errorcode:time:text) -> LogMessage Error (read errorcode) (read time) (unwords text)<br>
  Â  Â  Â  _  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ->  Unknown "This is not in the right format"<br></blockquote><div><br></div><div>The code looks just fine. Great work.</div><div>The trouble is with the third case. The error message is fairly instructive.</div><div><br></div><div><div><font face="monospace, monospace">log.hs:19:36:</font></div><div><font face="monospace, monospace">  Â  Couldn't match expected type â€˜String -> LogMessage’</font></div><div><font face="monospace, monospace">  Â  Â  Â  Â  Â  Â  Â  with actual type â€˜LogMessage’</font></div><div><font face="monospace, monospace">  Â  The function â€˜LogMessage’ is applied to four arguments,</font></div><div><font face="monospace, monospace">  Â  but its type â€˜MessageType -> TimeStamp -> String -> LogMessage’</font></div><div><font face="monospace, monospace">  Â  has only three</font></div><div><font face="monospace, monospace">  Â  In the expression:</font></div><div><font face="monospace, monospace">  Â  Â  LogMessage Error (read errorcode) (read time) (unwords text)</font></div><div><font face="monospace, monospace">  Â  In a case alternative:</font></div><div><font face="monospace, monospace">  Â  Â  Â  ("E" : errorcode : time : text)</font></div><div><font face="monospace, monospace">  Â  Â  Â  Â  -> LogMessage Error (read errorcode) (read time) (unwords text)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">log.hs:19:47:</font></div><div><font face="monospace, monospace">  Â  Couldn't match expected type â€˜MessageType’</font></div><div><font face="monospace, monospace">  Â  Â  Â  Â  Â  Â  Â  with actual type â€˜Int -> MessageType’</font></div><div><font face="monospace, monospace">  Â  Probable cause: â€˜Error’ is applied to too few arguments</font></div><div><font face="monospace, monospace">  Â  In the first argument of â€˜LogMessage’, namely â€˜Error’</font></div><div><font face="monospace, monospace">  Â  In the expression:</font></div><div><font face="monospace, monospace">  Â  Â  LogMessage Error (read errorcode) (read time) (unwords text)</font></div></div><div><br></div><div>Long story short, you meant to write</div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  Â  LogMessage (Error (read errorcode)) ...</font></div><div><font face="monospace, monospace"><br></font></div>instead of</div><div class="gmail_quote"><br><div><font face="monospace, monospace">  Â  LogMessage Error (read errorcode) ... Â  Â  Â  Â -- Too many arguments to LogMessage (error message 1)</font></div><div><font face="monospace, monospace">  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â -- Too few arguments to Error (error message 2)</font></div><div><br></div><div>which is a very common error.</div></div>
</div></div>