diff options
author | ross <unknown> | 2003-04-25 10:50:06 +0000 |
---|---|---|
committer | ross <unknown> | 2003-04-25 10:50:06 +0000 |
commit | eb12972c9b217d46397791c63d19c418b1a3c83f (patch) | |
tree | 2a9cd6bbbbb68ac69bd3991f9486f09a6a8108dd /src/HaddockHtml.hs | |
parent | 6be4db86fa1f4a913db1e4703148edc83dc325e5 (diff) |
[haddock @ 2003-04-25 10:50:05 by ross]
An 80% solution to generating derived instances. A complete solution
would duplicate the instance inference logic, but if a type variable
occurs as a constructor argument, then we can just propagate the derived
class to the variable. But we know nothing of the constraints on any
type variables that occur elsewhere. For example, the declarations
data Either a b = Left a | Right b deriving (Eq, Ord)
data Ptr a = Ptr Addr# deriving (Eq, Ord)
newtype IORef a = IORef (STRef RealWorld a) deriving Eq
yield the instances
(Eq a, Eq b) => Eq (Either a b)
(Ord a, Ord b) => Ord (Either a b)
Eq (Ptr a)
Ord (Ptr a)
(??? a) => Eq (IORef a)
The last example shows the limits of this local analysis.
Note that a type variable may be in both categories: then we know a
constraint, but there may be more, or a stronger constraint, e.g.
data Tree a = Node a [Tree a] deriving Eq
yields
(Eq a, ??? a) => Eq (Tree a)
Diffstat (limited to 'src/HaddockHtml.hs')
0 files changed, 0 insertions, 0 deletions