This might me a stupid question, but since I don't have anyone to discuss it over a coffee, I think I'd ask it here. So, I'm reading the book "The Haskell School of Expression" to learn myself a bit of Haskell and they have the following type:
data Picture = Region Color Region | Picture `Over` Picture | EmptyPic deriving Show
Later, when they need to convert a picture into a list of regions they do it recursively like this:
picToList EmptyPic =  picToList (Region c r) = [(c, r)] picToList (p1 'Over' p2) = picToList p1 ++ picToList p2
This is all good and rather easy, but what made me thinking is that they had to do it manually. Haskell is packed with abstractions, so I wonder, does it have an abstraction for iterating over recursive data types? After all, the compiler knows the structure of the data type, and internally it probably represents the data as a graph of some kind, so can it traverse it for me via some generic way? I've no idea how it would work in practice, but still, Haskell is different enough from all the others programming languages I know, so, maybe there is some concept I can't even imagine that does it.