Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (39 sloc) 1.308 kB
module Portage.Use (
-- * main structures
UseFlag(..),
Use,
dispUses,
-- * helpers
mkUse,
mkNotUse,
mkQUse
) where
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import Distribution.Text ( Text(..) )
-- | Use variable modificator
data UseFlag = UseFlag Use -- ^ no modificator
| E UseFlag -- ^ = modificator (Equiv mark)
| Q UseFlag -- ^ ? modificator (Question mark)
| X UseFlag -- ^ ! modificator (eXclamation mark)
| N UseFlag -- ^ - modificator
deriving (Eq,Show,Ord,Read)
-- |
mkUse :: Use -> UseFlag
mkUse = UseFlag
mkNotUse :: Use -> UseFlag
mkNotUse = UseFlag
mkQUse :: Use -> UseFlag
mkQUse = Q . UseFlag
instance Text UseFlag where
disp = showModificator
showModificator :: UseFlag -> Disp.Doc
showModificator (UseFlag u) = Disp.text u
showModificator (X u) = Disp.char '!' <> disp u
showModificator (Q u) = disp u <> Disp.char '?'
showModificator (E u) = disp u <> Disp.char '='
showModificator (N u) = Disp.char '-' <> disp u
dispUses :: [UseFlag] -> Disp.Doc
dispUses [] = Disp.empty
dispUses us = Disp.brackets $ Disp.hcat $ (Disp.punctuate (Disp.text ", ")) $ map disp us
type Use = String
Jump to Line
Something went wrong with that request. Please try again.