-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A package for working with bit masks and flags in general. -- -- This package provides type classes for flags and corresponding -- instances for standard numeric types viewed as bit masks. @package data-flags @version 0.0.3.1 -- | Template Haskell utils for declaring flags instances. module Data.Flags.TH -- | Produces Flags instance declaration for the specified instance -- of Bits. dataBitsAsFlags :: Name -> Q [Dec] -- | Produces Flags and BoundedFlags instances declarations -- for the specified instance of Bits. dataBitsAsBoundedFlags :: Name -> Q [Dec] -- | Declare a newtype wrapper around the specified integral type and make -- it an instance of BoundedFlags. For each individual flag -- declare a constant. If a Show instance wasn't requested for -- automatic derivation, declare one with -- --
-- show flags = "WrappingTypeName [IndividualFlags in flags]" --bitmaskWrapper :: String -> Name -> [Name] -> [(String, Integer)] -> Q [Dec] -- | Declare an ADT with the specified constructors and make it an instance -- of Eq, Ord, Show and Storable. enumADT :: String -> Name -> [(String, Integer)] -> Q [Dec] -- | 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 --module Data.Flags class Eq a => Flags a noFlags :: Flags a => a andFlags :: Flags a => a -> a -> a butFlags :: Flags a => a -> a -> a commonFlags :: Flags a => a -> a -> a -- | Alias for andFlags. (.+.) :: Flags a => a -> a -> a -- | Alias for butFlags. (.-.) :: Flags a => a -> a -> a -- | Alias for commonFlags. (.*.) :: Flags a => a -> a -> a -- | Use this class when the set of flags is fixed and not likely to change -- in the future. class Flags a => BoundedFlags a allFlags :: BoundedFlags a => a enumFlags :: BoundedFlags a => a -> [a] -- | Shorthand for allFlags .-. x. allBut :: BoundedFlags a => a -> a -- | Test if the first flag set contains all flags from the second. containsAll :: Flags a => a -> a -> Bool -- | Shorthand for flip containsAll. (.<=.) :: Flags a => a -> a -> Bool -- | Alias for containsAll. (.>=.) :: Flags a => a -> a -> Bool -- | Test if two flag sets intersect. containsSome :: Flags a => a -> a -> Bool -- | Alias for containsSome. (.~.) :: Flags a => a -> a -> Bool -- | Test if two flag sets do not intersect. containsNone :: Flags a => a -> a -> Bool -- | Alias for containsNone. (./~.) :: Flags a => a -> a -> Bool instance BoundedFlags CULLong instance Flags CULLong instance BoundedFlags CLLong instance Flags CLLong instance BoundedFlags CULong instance Flags CULong instance BoundedFlags CLong instance Flags CLong instance BoundedFlags CUInt instance Flags CUInt instance BoundedFlags CInt instance Flags CInt instance BoundedFlags CUShort instance Flags CUShort instance BoundedFlags CShort instance Flags CShort instance BoundedFlags CUChar instance Flags CUChar instance BoundedFlags CSChar instance Flags CSChar instance BoundedFlags CChar instance Flags CChar instance BoundedFlags WordPtr instance Flags WordPtr instance BoundedFlags IntPtr instance Flags IntPtr instance BoundedFlags Word64 instance Flags Word64 instance BoundedFlags Word32 instance Flags Word32 instance BoundedFlags Word16 instance Flags Word16 instance BoundedFlags Word8 instance Flags Word8 instance BoundedFlags Word instance Flags Word instance BoundedFlags Int64 instance Flags Int64 instance BoundedFlags Int32 instance Flags Int32 instance BoundedFlags Int16 instance Flags Int16 instance BoundedFlags Int8 instance Flags Int8 instance BoundedFlags Int instance Flags Int instance Flags Integer