HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleoptics-core-0.4.1.1Haskell2010

Numeric.Optics

  • 12 values
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] ^.. traversed % 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 %~ (+3)5.003
Example1 expression
let fahrenheit = multiplying (9/5) % adding 32 in 230 ^. re fahrenheit110.0
valuenegated :: Num a => Iso' a a
#
negated = iso negate negate
Example1 expression
au (coerced1 @Sum % negated) (foldMapOf each) (3,4) == 7True
Example1 expression
au (coerced1 @Sum) (foldMapOf (each % negated)) (3,4) == -7True