1module Distribution.Types.AnnotatedId (
2    AnnotatedId(..)
3) where
4
5import Prelude ()
6import Distribution.Compat.Prelude
7
8import Distribution.Package
9import Distribution.Types.ComponentName
10
11-- | An 'AnnotatedId' is a 'ComponentId', 'UnitId', etc.
12-- which is annotated with some other useful information
13-- that is useful for printing to users, etc.
14--
15-- Invariant: if ann_id x == ann_id y, then ann_pid x == ann_pid y
16-- and ann_cname x == ann_cname y
17data AnnotatedId id = AnnotatedId {
18        ann_pid   :: PackageId,
19        ann_cname :: ComponentName,
20        ann_id    :: id
21    }
22    deriving (Show)
23
24instance Eq id => Eq (AnnotatedId id) where
25    x == y = ann_id x == ann_id y
26
27instance Ord id => Ord (AnnotatedId id) where
28    compare x y = compare (ann_id x) (ann_id y)
29
30instance Package (AnnotatedId id) where
31    packageId = ann_pid
32
33instance Functor AnnotatedId where
34    fmap f (AnnotatedId pid cn x) = AnnotatedId pid cn (f x)
35