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

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