Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic Use types support

  • Loading branch information...
commit 2d9bb512efad35f648dd27a87d9eba872b4ef847 1 parent 598cc13
Alexander Vershilov qnikst authored
Showing with 46 additions and 0 deletions.
  1. +46 −0 Portage/Use.hs
46 Portage/Use.hs
View
@@ -0,0 +1,46 @@
+module Portage.Use (
+ -- * main structures
+ UseFlag(..),
+ Use,
+ -- * 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
+
+
+type Use = String
+
Please sign in to comment.
Something went wrong with that request. Please try again.