I'm quite new to Haskell and i'm not sure how to solve / approach this problem: I want a function with the type signature: [((Double, Double), Bool)] -> [[(Double, Double)]]. The function should only add (Double, Double) to the list of lists if Bool == True. If the bool is False, I want the (Double, Double) associated with the next True bool to be added to a new list. Consecutive (Double, Double)'s paired with Bool == True should be added to the same list. For example, an input of: [((1,1),True),((2,2), False),((3,3), False),((4,4),True),((5,5),True)] should return [[(1,1)],[(4,4),(5,5)]]. I did a little research and it seems like the groupBy function might be useful in solving the problem, but I'm not quite sure how to use it properly. As I'm new new to Haskell I'd prefer a more simple solution or explanation but any suggestions would help.
So far my code just creates a new list for every (Double, Double) associated with True bool. I'm not quite sure how to add to an existing list within a list.
consecTrue :: [((Double, Double),Bool)] -> [[(Double,Double)]]
consecTrue xs = case xs of
[] -> []
x:xs
|snd x == True -> [fst x]:consecTrue xs
|snd x == False -> consecTrue xs