<div><div dir="auto">Parentheses in Haskell aren’t really related to function application, they are only for grouping. It makes more sense if you avoid using them unless strictly necessary.</div></div><div dir="auto"><br></div><div dir="auto">In Haskell instead of `f(g(x))` we would write `f (g x)`, and instead of `f(x,g(y),z)` we would write `f x (g y) z`. You could use more parentheses but it would be more confusing, such as `(f)(x)(g(y))(z)`.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 28, 2020 at 05:50 Josh Friedlander <<a href="mailto:joshuatfriedlander@gmail.com">joshuatfriedlander@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks Francesco, that works. I don't quite understand what the issue was, though. Specifically: <br></div><div>- Did the parentheses around (xs) hurt, or were they just redundant?</div><div>- Wouldn't the parentheses around (head ...) be binding it as an argument to whatever comes before (in this case, 3)?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 28 Jun 2020 at 14:47, Francesco Ariis <<a href="mailto:fa-ml@ariis.it" target="_blank">fa-ml@ariis.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Josh<br>
<br>
Il 28 giugno 2020 alle 14:36 Josh Friedlander ha scritto:<br>
> I want to create a log parser like this:<br>
> <br>
> module LogAnalysis where<br>
> import Log<br>
> <br>
> parseMessage :: String -> LogMessage<br>
> parseMessage xs<br>
> | length(words(xs)) < 3 = Unknown xs<br>
> | notElem(head(words(xs)) ["I", "E", "W"]) = Unknown xs<br>
> | otherwise = LogMessage Info 3 head(words(xs))<br>
> <br>
> But GHC gives me "• Couldn't match type ‘[a0] -> a0’ with ‘[Char]’<br>
> Expected type: String<br>
> Actual type: [a0] -> a0"<br>
<br>
I suspect `LogMessage Info 3 head(words(xs))` is the problem. This is<br>
the same as writing<br>
<br>
LogMessage Info 3 head (words xs)<br>
<br>
keeping in mind how whitespace and parentheses work in Haskell. You<br>
probably want<br>
<br>
LogMessage Info 3 (head (words xs))<br>
<br>
instead.<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div></div>