Hello --

I'm wondering if there is any work (and interest) on supporting user-defined optimizations similar to GHC's rewrite rules in the Ocaml compiler. For example, a standard example would be specifying map fusion:

map f (map g ls) = map (fun x -> f (g x)) ls

This works well in Haskell due to laziness and (mostly) purity but things are obviously more complex in Ocaml since you can not pretend that things are pure (due to exceptions, references, IO, and non-termination).

On a related note, this sort of optimization could require a reasonable amount of static analysis for effects (or trying to reflect effects in the type system). Has there been any work related to this?

Thank you.

--
gregory malecha