HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelens-5.3.5Haskell2010

Numeric.Lens

  • 12 values
  • Packagelens-5.3.5
  • Exports13
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceLens.hs
valuebase :: (HasCallStack, Integral a) => Int -> Prism' String a
#

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

Note: This is an improper prism, since leading 0s are stripped when reading.

Example1 expression
"100" ^? base 16Just 256
Example1 expression
1767707668033969 ^. re (base 36)"helloworld"

Predefined bases

4 declarations

Arithmetic lenses

7 declarations
valueadding :: Num a => a -> Iso' a a
#
adding n = iso (+n) (subtract n)
Example1 expression
[1..3]^..traverse.adding 1000[1001,1002,1003]
valuemultiplying :: (Fractional a, Eq a) => a -> Iso' a a
#
multiplying n = iso (*n) (/n)

Note: This errors for n = 0

Example1 expression
5 & multiplying 1000 +~ 35.003
Example1 expression
let fahrenheit = multiplying (9/5).adding 32 in 230^.from fahrenheit110.0
valueexponentiating :: (Floating a, Eq a) => a -> Iso' a a
#
exponentiating n = iso (**n) (**recip n)

Note: This errors for n = 0

Example1 expression
au (_Wrapping Sum . from (exponentiating 2)) (foldMapOf each) (3,4) == 5True
valuenegated :: Num a => Iso' a a
#
negated = iso negate negate
Example1 expression
au (_Wrapping Sum . negated) (foldMapOf each) (3,4) == 7True
Example1 expression
au (_Wrapping Sum) (foldMapOf (each.negated)) (3,4) == -7True