Re: Private classes

2013-08-17 Thread Bas van Dijk
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 m...@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
   m...@joachim-breitner.de • http://www.joachim-breitner.de/
   Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
   Debian Developer: nome...@debian.org


 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Private classes

2013-08-17 Thread Joachim Breitner
Hi,

Am Samstag, den 17.08.2013, 20:34 +0200 schrieb Bas van Dijk:
 I used the following in the past:
 
 module M (PublicClass(..)) where
 
 class HiddenClass a
 
 class HiddenClass a = PublicClass a where
   ...

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

nice idea! Unfortunately not quite what I need; I still want the user to
be able to use standalone deriving instances for the class.

Greetings,
Joachim

-- 
Joachim “nomeata” Breitner
  m...@joachim-breitner.de • http://www.joachim-breitner.de/
  Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nome...@debian.org


signature.asc
Description: This is a digitally signed message part
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Private classes

2013-08-17 Thread migmit
Do you mean GeneralizedNewtypeDeriving?

Отправлено с iPad

17.08.2013, в 23:49, Joachim Breitner m...@joachim-breitner.de написал(а):

 Hi,
 
 Am Samstag, den 17.08.2013, 20:34 +0200 schrieb Bas van Dijk:
 I used the following in the past:
 
 module M (PublicClass(..)) where
 
 class HiddenClass a
 
 class HiddenClass a = PublicClass a where
  ...
 
  ...
 
 Now users of M can't declare instances of PublicClass because they
 don't have its superclass HiddenClass in scope.
 
 nice idea! Unfortunately not quite what I need; I still want the user to
 be able to use standalone deriving instances for the class.
 
 Greetings,
 Joachim
 
 -- 
 Joachim “nomeata” Breitner
  m...@joachim-breitner.de • http://www.joachim-breitner.de/
  Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nome...@debian.org
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Private classes

2013-08-17 Thread Edward A Kmett
My usual variant of this is to use

class Foo' a

class Foo' a = Foo a
instance Foo' a = Foo a

and not export Foo'

Sent from my iPhone

On Aug 17, 2013, at 2:34 PM, Bas van Dijk v.dijk@gmail.com wrote:

 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 m...@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
   m...@joachim-breitner.de • http://www.joachim-breitner.de/
   Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
   Debian Developer: nome...@debian.org
 
 
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Private classes

2013-08-17 Thread Edward A Kmett
If you don't export the methods but do use DefaultSignatures for them in terms 
of a GHC.Generics version of the class that also works in many cases.

Sent from my iPhone

On Aug 17, 2013, at 2:08 PM, Joachim Breitner m...@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
  m...@joachim-breitner.de • http://www.joachim-breitner.de/
  Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nome...@debian.org
 
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users