Ralf Hinze wrote:
What happens if the tree contains additional integers to record, say, balancing information. The information a functor provides is vital here. Take as the simplest example
newtype Weighted a = WithWeight (Int, a)
Without the functor definition there is no way to distinguish the two Ints in Weighted Int.
You are right in that gmapping is not generally aware of term components that relate to the parameter of a parameterised datatype. This has to do with the restricted structural induction and with the bias towards nominal type case. One can still recover `type distinctions' by pattern matching however. I elaborated the example like this: http://www.cs.vu.nl/boilerplate/testsuite/foldTree.hs (More generally, it is certainly debatable if the gmap combinators are in place for more fancy datatypes, e.g., nested datatypes. I mean that the design and use of these datatypes is normally an ingenious process as opposed to boilerplate programming in the sense of AST or document traversal.) Ralf L. -- Ralf Laemmel VU & CWI, Amsterdam, The Netherlands http://www.cs.vu.nl/~ralf/ http://www.cwi.nl/~ralf/