An exciting new compiler optimization landed on our master branch today, and we’re looking for adventurous souls to test it out!
The PR in question is https://github.com/purescript/purescript/pull/3915, which has been waiting in the wings for a while now for the right time to be merged. This optimization selectively generates variables for instantiated type class members in a parent scope, so that instead of this:
var ap = function (dictMonad) {
return function (f) {
return function (a) {
return Control_Bind.bind(dictMonad.Bind1())(f)(function (f$prime) {
return Control_Bind.bind(dictMonad.Bind1())(a)(function (a$prime) {
return Control_Applicative.pure(dictMonad.Applicative0())(f$prime(a$prime));
});
});
};
};
};
you’ll see this:
var ap = function (dictMonad) {
var bind = Control_Bind.bind(dictMonad.Bind1());
var pure = Control_Applicative.pure(dictMonad.Applicative0());
return function (f) {
return function (a) {
return bind(f)(function (f$prime) {
return bind(a)(function (a$prime) {
return pure(f$prime(a$prime));
});
});
};
};
};
I expect this to have positive effects on bundle sizes and run-time performance for many projects, particularly ones that make heavy use of classes and eta-reduced curried functions. For example, I cooked up this version of the benchmark graph from @PureFunctor’s recently-announced uncurried-transformers
project:
But this is a big change internally, and causes code to be evaluated in a different order (instance members can now be evaluated earlier than the expressions that use them). So this message goes out to anyone who wants to help us find any lurking issues related to this before we get around to releasing 0.15.3.
Simply use any prerelease build >=0.15.3-1, be sure to wipe all of your output code, and let us know here or on GitHub about any issues you encounter. If things go well for you, a note here in this thread would also be appreciated, to give us confidence that enough people have tried it out.
Thanks for helping out!