lens-3.10: Lenses, Folds and Traversals

Portability | portable
Stability | provisional
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | None

Numeric.Lens

Contents

- Predefined bases

Description

Synopsis

- 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

# Documentation

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

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

    >>> "100" ^? base 16
    Just 256

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

integral :: (Integral a, Integral b) => Prism Integer Integer a bSource

This `Prism` extracts can be used to model the fact that every `Integral` type is a subset of `Integer`.

Embedding through the `Prism` only succeeds if the `Integer` would pass through unmodified when re-extracted.

# Predefined bases

binary :: Integral a => Prism' String aSource

    binary = base 2

octal :: Integral a => Prism' String aSource

    octal = base 8

decimal :: Integral a => Prism' String aSource

    decimal = base 10

hex :: Integral a => Prism' String aSource

    hex = base 16