user1351008
user1351008

Reputation: 63

Why is there a parse error?

Why is there a parse error on this? I insert a list and want to get tuples out. (The top line is correct).

freq :: Eq a => [a] -> [(Int,a)]
freq x:xs  = [(x,y)| (x,y) x <- count , y <- rmdups]

Upvotes: 1

Views: 167

Answers (2)

Cat Plus Plus
Cat Plus Plus

Reputation: 129754

There are two syntax errors here — no parenthesis on the pattern, and wrongly placed (x,y) inside the comprehension. It should be:

freq (x : xs) = [(x, y) | x <- count, y <- rmdups]

Upvotes: 6

hugomg
hugomg

Reputation: 69924

You have to put parenthesis in your pattern match

freq (x:xs) = {- ... -}

Upvotes: 1

Related Questions