<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hey Alexander,</p>
<p><code>dict</code> has type <code>String</code>. Therefore, <code>x</code>
is of type <code>Char</code>, but <code>elem '-'</code> is of
type <code>[Char] -> Bool</code> (simplified). Hence, you get
a type mismatch. If you just want to count every character except
<code>'-'</code>, then you could just you <code>'-' /= x</code>.
<br>
</p>
<p>Cheers</p>
<p>Tobias<br>
</p>
<div class="moz-cite-prefix">On 8/13/20 1:02 PM, Alexander Chen
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:252977439.222507.1597316539010@ichabod.co-bxl">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div style="font-family:Arial; font-size:13px;">Hi,
<div><br>
</div>
<div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #569cd6;">module</span> <span style="color: #4ec9b0;">Main</span> <span style="color: #569cd6;">where</span></div>
<div><span style="color: #dcdcaa;">allwords</span> :: <span style="color: #569cd6;">IO</span> <span style="color: #569cd6;">Int</span></div><div>allwords = <span style="color: #c586c0;">do</span></div><div> dict <- readFile <span style="color: #ce9178;">"data/dict.txt"</span></div><div> return $ length [x | x <- dict , not $ <span style="color: #ce9178;">'-'</span> `elem` x]</div><div> </div><div><span style="color: #dcdcaa;">main</span> :: <span style="color: #569cd6;">IO</span> <span style="color: #569cd6;">Int</span></div><div>main = <span style="color: #c586c0;">do</span> allwords</div></div>
<br>
<div>
<div style="font-family:Arial; font-size:13px;">error</div>
</div>
</div>
<div style="font-family:Arial; font-size:13px;"><br>
</div>
<div style="font-family:Arial; font-size:13px;">
<div>* Couldn't match expected type `t0 Char' with actual type
`Char'</div>
<div>* In the second argument of `elem', namely `x'</div>
<div> In the second argument of `($)', namely '-' `elem` x</div>
<div> In the expression: not $ '-' `elem` x</div>
<div><br>
</div>
<div><br>
</div>
<div>could someone tell me what I am doing wrong?</div>
<div><br>
</div>
<div>thanks!</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
</body>
</html>