
On Tue, Aug 24, 2010 at 01:09:56PM +0200, Thomas wrote:
But if I change the type declaration of 'testFold' to: testFold :: XMLCallback a it will not compile.
I thought that 'a' is a type /variable/ thus able to hold any type, for example, but not limited to '[(XMLTreeNode, [Int], [XMLTreeNode])]'. Why do I need to be that much more specific in the declaration for 'testFold'?
Daniel has already given a more detailed answer, but just to emphasize the main point a bit more: testFold :: XMLCallback a means that testFold *should work no matter what a is*. But as Daniel has explained, this is not the case; testFold only works for certain specific types in place of a. Type variables are not a shortcut used when one can't be bothered to give the type in more detail; rather, they are strong assertions that *any type will work*. -Brent