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

Modulelens-5.3.5Haskell2010

Data.Complex.Lens

Lenses and traversals for complex numbers

  • 6 values
  • Packagelens-5.3.5
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceLens.hs
value_phase :: RealFloat a => Lens' (Complex a) a
#

Access the phase of a Complex number.

Example1 expression
(mkPolar 10 (2-pi) & _phase +~ pi & view _phase) ≈ 2True

This isn't quite a legal Lens. Notably the

view l (set l b a) = b

law is violated when you set a phase outside the range (-pi, pi]. The phase is always in that range when queried. So don't do that!

Otherwise, this is a perfectly cromulent Lens.

Pattern Synonyms

4 declarations