3 ms·
What exactly do you mean by conflicting? Remember that the types, typeclasses and function implementations are all namespaced, so name collisions here are fine.
by clusmore 10y ago
What exactly do you mean by conflicting? Remember that the types, typeclasses and function implementations are all namespaced, so name collisions here are fine. The only problem occurs when you define multiple instances for a type and a typeclass (e.g. Int is a Monoid as a sum and separately Int is a Monoid as a product) and you attempt to import both instances into the same module, called Overlapping Instances. But if the usage of the overlapping instances is not ambiguous it wont' cause any problems.
Even the following is perfectly fine:
-- sum.hs
module Sum where
instance Monoid Int where
mappend = (+)
mempty = 0
ten :: Int
ten = mconcat [1..4]
-- product.hs
module Product where
instance Monoid Int where
mappend = (*)
mempty = 1
twentyfour :: Int
twentyfour = mconcat [1..4]
-- usage.hs
import Sum
import Product
twohundredforty :: Int
twohundredforty = ten * twentyfour
- deleted 10y ago[deleted]