I am trying to figure out how to write this function with the Eq function in Haskell.
An easy function that I am trying to implement is:
f :: Eq a =>
You can also use span and a recursive call to make it work:
f :: Eq a => [a] -> [[a]] f [] = [] f l@(x:xs) = grouped : f remainder where (grouped, remainder) = span (== x) l
Here you have the live example