(** Rotation on the vect(x,y) plane with an angle t(where V is a vector module, R the associated real-like field and |*| the scalar product)
precondition: x and y are orthonormal *)
let rotation (x,y) t v = let open V in
v
+ R.( ( cos t - 1. ) * (v|*|x) - sin t * (v|*|y) ) * x
+ R.( sin t * (v|*|x) + ( cos t - 1. ) * (v|*|y) ) * y
let rotation (x,y) t v =with your proposition.
v
V.+ ( ( cos t R.- 1. ) R.* ( v V.|*| x ) R.- sin t R.* ( v V.|*| y ) ) V.* x
V.+ ( sin t R.* ( v V.|*| x ) R.+ ( cos t R.- 1. ) R.* ( v V.|*| y ) ) V.* y
This whole thread makes me wonder whether local opens are worth it. I don't like global open (at all), and shadowing is harmful even in smaller scopes. Local open seems to be used for DSL that have a lot of infix operators (maths, etc.) as demonstrated by the proposal of new warnings and syntax about shadowing of infix operators.
If modules have short names (Z, Q from Zarith come to mind, but module-aliasing your favorite monad to "M" would do too), would M.+ be a reasonable infix operator? I would be ready to have slightly more verbose calls to M.>>= if it removes ambiguity and potential shadowing bugs. Of course I don't know if this is compatible with the current syntax.
--
Simon