Safe Haskell | None |
---|---|
Language | Haskell98 |
This module provides type classes for working with sets of flags. In particular, with wrappers around bit masks:
import Data.Flags newtype MyFlags = MyFlags CInt deriving (Eq, Flags) #{enum MyFlags, MyFlags , myFlag1 = C_FLAG1 , myFlag2 = C_FLAG2 , myFlag3 = C_FLAG3 } f :: MyFlags -> IO () f = ...
Or, using Template Haskell:
import Data.Flags.TH $(bitmaskWrapper "MyFlags" ''CInt [] False [("myFlag1", #{const C_FLAG1}), ("myFlag2", #{const C_FLAG2}), ("myFlag3", #{const C_FLAG3})])
And then use it like this:
f $ myFlag1 .+. myFlag3
- class Eq α => Flags α where
- (.+.) :: Flags α => α -> α -> α
- (.-.) :: Flags α => α -> α -> α
- (.*.) :: Flags α => α -> α -> α
- class Flags α => BoundedFlags α where
- allBut :: BoundedFlags α => α -> α
- containsAll :: Flags α => α -> α -> Bool
- (.<=.) :: Flags α => α -> α -> Bool
- (.>=.) :: Flags α => α -> α -> Bool
- containsSome :: Flags α => α -> α -> Bool
- (.~.) :: Flags α => α -> α -> Bool
- containsNone :: Flags α => α -> α -> Bool
- (./~.) :: Flags α => α -> α -> Bool
Documentation
(.*.) :: Flags α => α -> α -> α infixl 7 Source #
Alias for commonFlags
.
class Flags α => BoundedFlags α where Source #
Use this class when the set of flags is fixed and not likely to change in the future.
containsAll :: Flags α => α -> α -> Bool infix 4 Source #
Test if the first flag set contains all flags from the second.
containsSome :: Flags α => α -> α -> Bool infix 4 Source #
Test if two flag sets intersect.
containsNone :: Flags α => α -> α -> Bool infix 4 Source #
Test if two flag sets do not intersect.