<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">And when Im trying this: <br>
<br>
{-# OPTIONS_GHC -Wall #-}<br>
<br>
module LogAnalysis where<br>
<br>
import Log;<br>
import Data.Char (isLetter, isDigit)<br>
<br>
isValid :: String -> Bool<br>
isValid s = go (words s)<br>
where<br>
go ([a]:b:_) = isLetter a && all isDigit b<br>
go _ = False<br>
<br>
<br>
-- | The main entry point.<br>
main :: IO ()<br>
main = do<br>
putStrLn $ isValid "I 4764 He trusts to you to set them free,"<br>
<br>
<br>
I see this error message : <br>
<br>
<div class="ide-error-span">src/LogAnalysis.hs@19:16-19:67 </div>
<div class="ide-error-msg"><span>Couldn't match type </span>
<div class="CodeMirror cm-s-default" style="font-size: 14px;"><span
class="cm-variable-2">Bool</span></div>
<span> with </span>
<div class="CodeMirror cm-s-default" style="font-size: 14px;">[<span
class="cm-variable-2">Char</span>]</div>
<span>
Expected type: String Actual type: Bool</span><span
title="Click to show/hide extra information"
class="ide-error-collapse-btn"> …</span><span style="display:
inline;">
In the second argument of ‘($)’, namely ‘isValid "I 4764 He
trusts to you to set them free,"’
In a stmt of a 'do' block: putStrLn $ isValid "I 4764 He
trusts to you to set them free,"<br>
<br>
Roelof<br>
<br>
</span></div>
<br>
<br>
<br>
<br>
Roelof Wobben schreef op 23-2-2015 om 17:19:<br>
</div>
<blockquote cite="mid:54EB5306.2050501@home.nl" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">I tried it another way more like
explained on this page : <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://www.seas.upenn.edu/%7Ecis194/spring13/lectures/02-ADTs.html">http://www.seas.upenn.edu/~cis194/spring13/lectures/02-ADTs.html</a><br>
<br>
so I tried this : <br>
<br>
parseMessage :: [Char] -> [Char]<br>
parseMessage s<br>
case Errornumber of <br>
IsDigit Errornumber -> "Geldige string"<br>
otherwise -> "Ongeldige string"<br>
where<br>
Error = s words<br>
Errornumber = Error(ErrorNumber _ _ )<br>
Errorcode = Error(_ Errorcode _ )<br>
<br>
but now I cannot use where :( <br>
<br>
Roelof<br>
<br>
<br>
<br>
<br>
Roelof Wobben schreef op 23-2-2015 om 16:10:<br>
</div>
<blockquote cite="mid:54EB42DB.6020509@home.nl" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Oke, <br>
<br>
Then I make there a mistake,<br>
<br>
What I try to do is to send the file to parseMessage and let
IsValid check if it´s have the right format. <br>
<br>
Then after the where I try to check if the function isValid
returns true or false. <br>
<br>
Roelof<br>
<br>
<br>
Konstantine Rybnikov schreef op 23-2-2015 om 16:03:<br>
</div>
<blockquote
cite="mid:CAAbahfS0Sq0hGJuis5hzLj5ZTzQALdZrAEq6AevjMUDSsnaa5g@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>Roelof,<br>
<br>
</div>
You defined isValid function in the upper-scope first,
and then you defined a symbol (variable) that re-wrote
that name to something different (string "Geldige
string"). That's why you get an error saying it doesn't
expect arguments.<br>
<br>
</div>
My suggestion is to rename second isValid.<br>
<br>
</div>
Good luck.<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Feb 23, 2015 at 4:50 PM,
Roelof Wobben <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:r.wobben@home.nl"
target="_blank">r.wobben@home.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Chaddaï Fouché schreef op 23-2-2015 om 13:20:<br>
</div>
<span class="">
<blockquote 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"
target="_blank">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>
</span> 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>src/LogAnalysis.hs@16:18-16:27 </div>
<div><span>Couldn't match expected type ‘[Char] ->
[Char]’ with actual type </span>
<div style="font-size:14px">[<span>Char</span>]</div>
<span> The function </span>
<div style="font-size:14px"><span>isValid</span></div>
<span> is applied to one argument, but its type </span>
<div style="font-size:14px">[<span>Char</span>]</div>
<span> has none</span><span title="Click to
show/hide extra information"> …</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>
</div>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Haskell-Cafe mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
</pre>
</blockquote>
<br>
</body>
</html>