HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulelens-5.3.6Haskell2010

Data.Complex.Lens

Lenses and traversals for complex numbers

Contents
  1. Pattern Synonyms
Synopsis
  • 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