2009/1/15 Peter Verswyvelen <bugfact@gmail.com>
When I first read about active patterns in F#, I found it really cool idea, since it allows creating fake data constructors that can be used for pattern matching, giving many views to a single piece of data, and allowing backwards compatibility when you completely change or hide a data structure.So for example one could define a Polar pattern and a Rect pattern that give different views of a Complex number, e.g (pseudo code follows)pattern Polar c = (mag c, phase c)pattern Rect c = (real c, imag c)This seems handy:polarMul (Polar m1 p1) (Polar m2 p2) = mkComplexFromPolar (m1*m2) (p1+p2)However, I think it is flawed, since the followingcase c ofPolar _ _ -> "it's polar!"Rect _ _ -> "it's rect!"seems like valid code but does not make any sense.