deriving...

Christian Maeder maeder at tzi.de
Wed Oct 20 06:00:59 EDT 2004


deriving instances will only work for
a) known/builtin classes (like Typeable, Eq, Show, etc)

b) datatypes T that are defined elsewhere using data (or newtype) where 
the corresponding deriving clause is missing.

HTH Christian

MR K P SCHUPKE wrote:
>>instance Typeable (T a)
> 
> 
> Forgive my stupid question, but why? What will deriving instances do?
> Questions that spring to mind are:
> 
> 1) How will the deriviation of instances be defined... If instances 
> are the same for all types then this is just the current default
> method. If not then this will need reflection to decompose the type and
> construct the method?
> 
> 2) How will validity be checked... Lets say I have a class called
> Set, and I make a type an instance of this class, how will it
> show that the properties of a 'set' are valid on the particular
> instance? (for example I try and make an 'Int' an instance of
> 'Set'.
> 
> Keean.
> 



More information about the Glasgow-haskell-users mailing list