HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleoptics-core-0.4.2Haskell2010

Numeric.Optics

  • 12 values
  • Packageoptics-core-0.4.2
  • Exports13
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceOptics.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] ^.. 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