lens-1.6: Lenses, Folds and Traversals

Portability LiberalTypeSynonyms provisional Edward Kmett Safe-Infered

Data.Bits.Lens

Description

Synopsis

# Documentation

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

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

````>>> ````_2 |~ 6 \$ ("hello",3)
```("hello",7)
```

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

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

````>>> ````_2 &~ 7 \$ ("hello",254)
```("hello",6)
```

(|=) :: (MonadState a m, Bits b) => Simple Setting 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 Setting 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.

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

````>>> ````16^.bitAt 4
```True
```
````>>> ````15^.bitAt 4
```False
```

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.