> In my NLP.Prelude file, I define:
> 
> > newtype Token = Token [Word8]
> 
> and I export only the type, not the constructor because I 
> don't users of
> my package to be able to inspect/modify the list directly.  
> However, in my
> NLP.IO module, in which I define IO for some of my data 
> types, I need to
> be able to access it directly.
> 
> In Java/C#, I would make Token public and the constructor 
> protected (i.e.,
> public for the current package but private for other people).  I would
> really like to be able to do something similar.  Any ideas?

Define the type in a private module, say DLP.Prelude.Private, which is
used by NLP.IO, and re-export it abstractly from NLP.Prelude.  You don't
get the benefit of language support for enforcing that
NLP.Prelude.Private isn't nefariously imported by the client, but at
least now with hierarchical modules the private module name isn't
polluting the client's module namespace.

Cheers,
        Simon
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to