
25 Nov
2009
25 Nov
'09
5:34 p.m.
Luke Palmer
I feel like this should be qualified. Type classes are not for name punning ; you wouldn't use a type class for the method bark on types Tree and Dog. But if you have a well-defined *structure* that many types follow, then a type class is how you capture that. It sounds like you do have this structure in your example.
Is there any way that type classes can manage name spaces to disambiguate functions like bark on types Tree and Dog? If constants are considered as unary functions, can we use constants in type classes and/or instances? How are local class specific constants, such as tank in Army/tank in Fish, bank in River/bank in Finance, handled? Pat