Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Documentation
encodeModifiers :: [Modifier] -> CULLong
Marshall the bitmask.
relates Haskell types with Objective-C types:
- Haskell list-of-enum ~ Objective-C bit-mask
- Haskell
[
~ Objective-CModifier
]CGEventFlags
- Haskell
CULLong
~ Objective-Cuint64_t
- Haskell can marshal
CULLong
Implementation
"Bit-vectors are interpreted as unsigned integers (i.e. natural numbers)"
the folded bitvector size, is the initial bitvector size. because:
>>>
toBits (zeros 5 .|. ones 2)
[False, False, False, True, True]
and:
>>>
foldl (+) 0 [1,2,3]
((0 + 1) + 2) + 3
since each bitmask
is disjoint, and we logical-OR the bits
together, we don't need to remove duplicates.