Private classes

Bas van Dijk v.dijk.bas at gmail.com
Sat Aug 17 20:34:59 CEST 2013


Hi Joachim,

I used the following in the past:

module M (PublicClass(..)) where

class HiddenClass a

class HiddenClass a => PublicClass a where
  ...

instance HiddenClass SomeType

instance PublicClass SomeType where
  ...

Now users of M can't declare instances of PublicClass because they don't
have its superclass HiddenClass in scope.

Regards,

Bas
On Aug 17, 2013 8:10 PM, "Joachim Breitner" <mail at joachim-breitner.de>
wrote:

> Hi,
>
> for some reason I was under the impression that if I don’t export the
> methods of a class, then no user of my module can create instances. But
> I was wrong and in fact they can; the methods will just all be bound to
> "error ...".
>
> Is there really no way to create a class so that no-one else can create
> any instances?
>
> Greetings,
> Joachim
>
> --
> Joachim “nomeata” Breitner
>   mail at joachim-breitner.dehttp://www.joachim-breitner.de/
>   Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
>   Debian Developer: nomeata at debian.org
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130817/10eae030/attachment.htm>


More information about the Glasgow-haskell-users mailing list