<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Chaddaï Fouché schreef op 23-2-2015 om
13:20:<br>
</div>
<blockquote
cite="mid:CANfjZRbae12+-LYKY12ouiwR=ua0wpbv4e9PSnaWhuobV6K89A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Note that Roelof is doing the CIS 194 Homework <a
moz-do-not-send="true"
href="http://www.seas.upenn.edu/%7Ecis194/fall14/hw/03-ADTs.pdf">http://www.seas.upenn.edu/~cis194/fall14/hw/03-ADTs.pdf</a>
(the older version of fall2014, not the one currently
running). This is much clearer than Roelof's description, and
gives among other information an algebraic datatype to
represent log messages.<br>
<br>
<br>
-- <br>
</div>
Jedaï<br>
</div>
</blockquote>
<br>
Correct and Im trying to do exercise 1 of Week 2,<br>
<br>
I have tried this solution : <br>
<br>
-- | Main entry point to the application.<br>
{-# OPTIONS_GHC -Wall #-}<br>
<br>
module LogAnalysis where<br>
<br>
import Log;<br>
import Data.Char (isLetter, isDigit) <br>
<br>
isValid :: [Char] -> Bool <br>
isValid s = go (words s)<br>
where<br>
go ([a]:b:_) = isLetter a && all isDigit b<br>
go _ = False <br>
<br>
parseMessage :: [Char] -> [Char]<br>
parseMessage s = isValid s <br>
where <br>
isValid = "Geldige string"<br>
_ = "Ongeldige string"<br>
<br>
-- | The main entry point.<br>
main :: IO ()<br>
main = do<br>
putStrLn $ parseMessage "I 4764 He trusts to you to set them
free," <br>
<br>
<br>
but I see this error message : <br>
<br>
<div class="ide-error-span">src/LogAnalysis.hs@16:18-16:27 </div>
<div class="ide-error-msg"><span>Couldn't match expected type
‘[Char] -> [Char]’ with actual type </span>
<div class="CodeMirror cm-s-default" style="font-size: 14px;">[<span
class="cm-variable-2">Char</span>]</div>
<span>
The function </span>
<div class="CodeMirror cm-s-default" style="font-size: 14px;"><span
class="cm-variable">isValid</span></div>
<span> is applied to one argument,
but its type </span>
<div class="CodeMirror cm-s-default" style="font-size: 14px;">[<span
class="cm-variable-2">Char</span>]</div>
<span> has none</span><span title="Click to show/hide extra
information" class="ide-error-collapse-btn"> …</span><span
style="display: inline;">
In the expression: isValid s
In an equation for ‘parseMessage’: parseMessage s = isValid s
where isValid = "Geldige string" _ = "Ongeldige string"<br>
<br>
<br>
</span></div>
<br>
</body>
</html>