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

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Modulelens-5.3.6Haskell2010

Data.Complex.Lens

Lenses and traversals for complex numbers

  • 6 values
  • Packagelens-5.3.6
  • 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