
What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already defined in the module? More in detail, consider this module: === module Peano (Z,S,C) where data Z data S a -- Not exported class Peano b where instance Peano Z where instance Peano a => Peano (S a) where -- Exported class Peano a => C a where === Would that limit the instances of the class C to the Peano type naturals? Thanks, Roberto Zunino.

On Sun, Mar 04, 2007 at 01:03:45AM +0100, Roberto Zunino wrote:
What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already defined in the module?
More in detail, consider this module: === module Peano (Z,S,C) where
data Z data S a
-- Not exported class Peano b where instance Peano Z where instance Peano a => Peano (S a) where
-- Exported class Peano a => C a where ===
Would that limit the instances of the class C to the Peano type naturals?
Correct. It would also work to omit C and just use a non-exported class directly, but your users will get mad that they can't write type signatures for their functions. Stefan

Yes, as far as I can tell, C would be limited to Z and S. Nice trick! -- Lennart On Mar 4, 2007, at 00:03 , Roberto Zunino wrote:
What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already defined in the module?
More in detail, consider this module: === module Peano (Z,S,C) where
data Z data S a
-- Not exported class Peano b where instance Peano Z where instance Peano a => Peano (S a) where
-- Exported class Peano a => C a where ===
Would that limit the instances of the class C to the Peano type naturals?
Thanks, Roberto Zunino. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Lennart Augustsson
-
Roberto Zunino
-
Stefan O'Rear