Portability | LiberalTypeSynonyms |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Infered |
- (|~) :: Bits c => Setting a b c c -> c -> a -> b
- (&~) :: Bits c => Setting a b c c -> c -> a -> b
- (|=) :: (MonadState a m, Bits b) => Simple Setting a b -> b -> m ()
- (&=) :: (MonadState a m, Bits b) => Simple Setting a b -> b -> m ()
- bitAt :: Bits b => Int -> Simple Lens b Bool
- traverseBits :: Bits b => SimpleIndexedTraversal Int b Bool
Documentation
bitAt :: Bits b => Int -> Simple Lens b BoolSource
This lens can be used to access the value of the nth bit in a number.
bitAt n
is only a legal Lens
into b
if 0 <= n < bitSize (undefined :: b)
>>>
16^.bitAt 4
True
>>>
15^.bitAt 4
False
traverseBits :: Bits b => SimpleIndexedTraversal Int b BoolSource
Traverse over all bits in a numeric type.
The bit position is available as the index.
>>>
toListOf traverseBits (5 :: Word8)
[True,False,True,False,False,False,False,False]
If you supply this an Integer, it won't crash, but the result will be an infinite traversal that can be productively consumed.