Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (39 sloc) 1.308 kb
2d9bb51 @qnikst Basic Use types support
qnikst authored
1 module Portage.Use (
2 -- * main structures
3 UseFlag(..),
4 Use,
df4bc0d @qnikst Portage/Uses diplay for use list added
qnikst authored
5 dispUses,
2d9bb51 @qnikst Basic Use types support
qnikst authored
6 -- * helpers
7 mkUse,
8 mkNotUse,
9 mkQUse
10 ) where
11
12 import qualified Text.PrettyPrint as Disp
13 import Text.PrettyPrint ((<>))
14 import Distribution.Text ( Text(..) )
15
16 -- | Use variable modificator
17 data UseFlag = UseFlag Use -- ^ no modificator
18 | E UseFlag -- ^ = modificator (Equiv mark)
19 | Q UseFlag -- ^ ? modificator (Question mark)
20 | X UseFlag -- ^ ! modificator (eXclamation mark)
21 | N UseFlag -- ^ - modificator
22 deriving (Eq,Show,Ord,Read)
23
24 -- |
25 mkUse :: Use -> UseFlag
26 mkUse = UseFlag
27
28 mkNotUse :: Use -> UseFlag
29 mkNotUse = UseFlag
30
31 mkQUse :: Use -> UseFlag
32 mkQUse = Q . UseFlag
33
34
35 instance Text UseFlag where
36 disp = showModificator
37
38 showModificator :: UseFlag -> Disp.Doc
39 showModificator (UseFlag u) = Disp.text u
40 showModificator (X u) = Disp.char '!' <> disp u
41 showModificator (Q u) = disp u <> Disp.char '?'
42 showModificator (E u) = disp u <> Disp.char '='
43 showModificator (N u) = Disp.char '-' <> disp u
44
df4bc0d @qnikst Portage/Uses diplay for use list added
qnikst authored
45 dispUses :: [UseFlag] -> Disp.Doc
46 dispUses [] = Disp.empty
47 dispUses us = Disp.brackets $ Disp.hcat $ (Disp.punctuate (Disp.text ", ")) $ map disp us
2d9bb51 @qnikst Basic Use types support
qnikst authored
48
49 type Use = String
50
Something went wrong with that request. Please try again.