doldol-0.4.1.1: Flag packer & handler for flaggable data

Safe HaskellNone
LanguageHaskell2010

Data.Flag.Simple

Synopsis

Documentation

encodeFlag :: (Foldable f, Bounded e, Enum e) => f e -> Flag Source #

Encode Flag from a given collection of Enum e

decodeFlag :: Enum e => Flag -> [e] Source #

Decode Flag to a list of Enum e

showFlag :: Flag -> String Source #

Show Flag as a binary digit String

showFlagFit :: (Bounded e, Enum e) => e -> Flag -> String Source #

Show Flag as a binary digit String with a minimum length

showFlagBy :: Int -> Flag -> String Source #

Show Flag as a binary digit String with a given length

readFlag :: String -> Flag Source #

Encode Flag from a given binary digit String

This allows any character which is not '0' or '1' as '1'

readFlagSub :: Bits a => [Char] -> a -> a Source #

readEnum :: Enum e => String -> [e] Source #

Encode Enum e from a given binary digit String

include :: Flag -> Flag -> Bool Source #

Check whether Flag f1 covers every positive bit in Flag f2

This implementations implies that when f2 == zeroBits then the results of include is same as exclude

exclude :: Flag -> Flag -> Bool Source #

Check whether Flag f1 does not cover any positive bit in Flag f2

about :: (Flag -> Flag -> b) -> Flag -> Flag -> Flag -> b Source #

Apply f with two latter Flag arguments under the first Flag

eqAbout :: Flag -> Flag -> Flag -> Bool Source #

Check whether two Flags are same or not under the first Flag

eqAbout fb f1 f2 = (fb .&. f1) == (fb .&. f2)

anyReq :: Flag -> Flag -> Bool Source #

Check any positive bit of req matches corresponding bit of obj

When req is zerobits, this returns True

allReq :: Flag -> Flag -> Bool Source #

Check every positive bit of req matches corresponding bit of obj