Thanks Francesco, that works. I don't quite understand what the issue was, though. Specifically:- Did the parentheses around (xs) hurt, or were they just redundant?- Wouldn't the parentheses around (head ...) be binding it as an argument to whatever comes before (in this case, 3)?_______________________________________________On Sun, 28 Jun 2020 at 14:47, Francesco Ariis <fa-ml@ariis.it> wrote:Hello Josh
Il 28 giugno 2020 alle 14:36 Josh Friedlander ha scritto:
> I want to create a log parser like this:
>
> module LogAnalysis where
> import Log
>
> parseMessage :: String -> LogMessage
> parseMessage xs
> | length(words(xs)) < 3 = Unknown xs
> | notElem(head(words(xs)) ["I", "E", "W"]) = Unknown xs
> | otherwise = LogMessage Info 3 head(words(xs))
>
> But GHC gives me "• Couldn't match type ‘[a0] -> a0’ with ‘[Char]’
> Expected type: String
> Actual type: [a0] -> a0"
I suspect `LogMessage Info 3 head(words(xs))` is the problem. This is
the same as writing
LogMessage Info 3 head (words xs)
keeping in mind how whitespace and parentheses work in Haskell. You
probably want
LogMessage Info 3 (head (words xs))
instead.
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners