HORIZON HASKELLDocslts/ghc-9.14.xb9228482026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · b922848 · 2026-10-12

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