lens-1.3: Lenses, Folds and Traversals

PortabilityLiberalTypeSynonyms
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Infered

Data.Bits.Lens

Description

 

Synopsis

Documentation

(|~) :: Bits c => Setter a b c c -> c -> a -> bSource

Bitwise .|. the target(s) of a Bool-valued Lens or Setter

(&~) :: Bits c => Setter a b c c -> c -> a -> bSource

Bitwise .&. the target(s) of a Bool-valued Lens or Setter

(|=) :: (MonadState a m, Bits b) => Simple Setter a b -> b -> m ()Source

Modify the target(s) of a Simple Lens, Setter or Traversal by computing its bitwise .|. with another value.

(&=) :: (MonadState a m, Bits b) => Simple Setter a b -> b -> m ()Source

Modify the target(s) of a Simple Lens, Setter or Traversal by computing its bitwise .&. with another value.

bitAt :: Bits b => Int -> Simple Lens b BoolSource

This lens can be used to access the value of the nth bit in a number.

bitsAt n is only a legal Lens into b if 0 <= n < bitSize (undefined :: b)

traverseBits :: Bits b => Simple Traversal b BoolSource

Traverse over all bits in a numeric type.

 ghci> 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.

 ghci> toListOf traverseBits 5
 [True,False,True,False,False,False,False,False,False,False,False,False...