
28 Jun
2020
28 Jun
'20
7:47 a.m.
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.