/
Types.hs
77 lines (66 loc) · 2.14 KB
/
Types.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
module Portage.Dependency.Types
(
SlotDepend(..)
, LBound(..)
, UBound(..)
, DRange(..)
, DAttr(..)
, DUse(..)
, Dependency(..)
) where
import Portage.PackageId
import Portage.Use
data SlotDepend = AnySlot -- nothing special
| AnyBuildTimeSlot -- ':='
| GivenSlot String -- ':slotno'
deriving (Eq, Show)
data LBound = StrictLB Version
| NonstrictLB Version
| ZeroB
deriving (Eq, Show)
instance Ord LBound where
compare ZeroB ZeroB = EQ
compare ZeroB _ = LT
compare _ ZeroB = GT
compare (StrictLB lv) (StrictLB rv) = compare lv rv
compare (NonstrictLB lv) (NonstrictLB rv) = compare lv rv
compare l r = error $ unlines ["i am too lazy to implement LBound: compare"
, show l
, show r]
data UBound = StrictUB Version -- <
| NonstrictUB Version -- <=
| InfinityB
deriving (Eq, Show)
instance Ord UBound where
compare InfinityB InfinityB = EQ
compare InfinityB _ = GT
compare _ InfinityB = LT
compare (NonstrictUB lv) (NonstrictUB rv) = compare lv rv
compare (StrictUB lv) (StrictUB rv) = compare lv rv
compare l r = error $ unlines ["i am too lazy to implement UBound: compare"
, show l
, show r]
data DRange = DRange LBound UBound
| DExact Version
deriving (Eq, Show)
data DAttr = DAttr SlotDepend [UseFlag]
deriving (Eq, Show)
-- Simplified version of 'UseFlag'
-- used as a guarding depend:
-- foo? ( ... )
-- !foo? ( ... )
data DUse = DUse (Bool, Use)
deriving (Eq, Show)
-- sort order:
-- a? < b?
-- a? < !a?
instance Ord DUse where
compare (DUse (lb, lname)) (DUse (rb, rname)) =
case compare lname rname of
EQ -> compare rb lb
v -> v
data Dependency = Atom PackageName DRange DAttr
| DependIfUse DUse Dependency
| DependAnyOf [Dependency]
| DependAllOf [Dependency]
deriving (Eq, Show)