Portability | portable |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | None |

- base :: Integral a => Int -> Prism' String a
- integral :: (Integral a, Integral b) => Prism Integer Integer a b
- binary :: Integral a => Prism' String a
- octal :: Integral a => Prism' String a
- decimal :: Integral a => Prism' String a
- hex :: Integral a => Prism' String a
- adding :: Num a => a -> Iso' a a
- subtracting :: Num a => a -> Iso' a a
- multiplying :: (Fractional a, Eq a) => a -> Iso' a a
- dividing :: (Fractional a, Eq a) => a -> Iso' a a
- exponentiating :: (Floating a, Eq a) => a -> Iso' a a

# Documentation

base :: Integral a => Int -> Prism' String aSource

A prism that shows and reads integers in base-2 through base-36

`>>>`

Just 256`"100" ^? base 16`

`>>>`

"helloworld"`1767707668033969 ^. re (base 36)`

# Predefined bases

# Arithmetic lenses

subtracting :: Num a => a -> Iso' a aSource

`subtracting`

n =`iso`

(subtract n) ((+n)`subtracting`

n =`from`

(`adding`

n)

multiplying :: (Fractional a, Eq a) => a -> Iso' a aSource

`multiplying`

n = iso (*n) (/n)

Note: This errors for n = 0

`>>>`

5.003`5 & multiplying 1000 +~ 3`

`>>>`

110.0`let fahrenheit = multiplying (9/5).adding 32 in 230^.from fahrenheit`

dividing :: (Fractional a, Eq a) => a -> Iso' a aSource

`dividing`

n =`iso`

(/n) (*n)`dividing`

n =`from`

(`multiplying`

n)

Note: This errors for n = 0

exponentiating :: (Floating a, Eq a) => a -> Iso' a aSource

`exponentiating`

n =`iso`

(**n) (**recip n)

Note: This errors for n = 0

`>>>`

5.0`au (exponentiating 2._Unwrapping Sum) (foldMapOf each) (3,4)`