Changes between Version 7 and Version 8 of TypeFunctions/ClassFamilies


Ignore:
Timestamp:
May 16, 2007 1:15:28 PM (7 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TypeFunctions/ClassFamilies

    v7 v8  
    2929  insert x s | x `elem` s = s 
    3030             | otherwise  = x:s 
    31 instance Eq a => C [] a 
     31 
     32instance Eq a => C [] a                   -- Tiresome instance 
    3233}}} 
    3334and sets as finite maps 
     
    3839  empty = Data.Map.empty 
    3940  insert x s = Data.Map.insert x () s 
    40 instance Ord a => C MapSet a 
     41 
     42instance Ord a => C MapSet a               -- Tiresome instance 
    4143}}} 
    42 we instantiate `C` differently for different type indexes.  The class-family instances have no members in this case, but use existing classes as a superclass to supply `insert` with the equality and ordering methods, respectively.  As we want to use these superclasses for sets of any element type of which we have an instance of the superclasses, we need a catch-all instance  for each class instance.  That is somewhat ugly especially, as it requires the use of `-fallow-undecidable-instances`. 
     44we instantiate `C` differently for different type indexes.   
     45 
     46The class-family instances have no members in this case, but use existing classes as a superclass to supply `insert` with the equality and ordering methods, respectively.  As we want to use these superclasses for sets of any element type of which we have an instance of the superclasses, we need a catch-all instance  for each class instance (the "tiresome instances" avove).  That is somewhat ugly especially, as it requires the use of `-fallow-undecidable-instances`.  Furthermore, if the class has no signatures, there is no other useful instance we could possibly give. 
     47 
     48SLPJ note: I wonder whether it is ever useful to have a class instance with signatures.  Suppose we only allowed the signature-free form?  That would simplify the explanation in many ways (e.g. no need to say whether class instances can themselves have assoicated types!), and loses no expressive power.  I don't think it loses much convenience either. 
    4349 
    4450=== The language extension ===