
You can define the methods with the same names in different modules,
then when you are importing them into the same module for use, use a
qualified import.
import qualified Dog
import qualified Tree
This will allow you to use exactly the syntax you described.
Dog.bark
Tree.bark
Plus if you only have to import one of these, it is an opportunity to
be implicit which about the module being used.
On Thu, Nov 26, 2009 at 6:34 AM, pbrowne
Luke Palmer
wrote 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
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe