You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 2, 2024. It is now read-only.
Some mention should go in the README that the generated code is not comparable to the handwritten one, in terms of perf. So one should be aware of that.
The "alternative without the syntax sugar" in the README has a few typos. I believe it should be this:
functiongetStreet(maybeUser){returnBelt_Option.flatMap(maybeUser,(function(user){returnBelt_Option.flatMap(user[/* info */0],(function(personalInfo){returnBelt_Option.flatMap(personalInfo[/* address */0],(function(address){returnBelt_Option.flatMap(address[/* street */0],(function(street){returnstreet.toUpperCase();}));}));}));}));}
So that's more or less (or perhaps exactly) the code produced by the ppx.
functiongetStreetExplicit(maybeUser){if(maybeUser!==undefined){varmatch=maybeUser[/* info */0];if(match!==undefined){varmatch$1=match[/* address */0];if(match$1!==undefined){varmatch$2=match$1[/* street */0];if(match$2!==undefined){returnmatch$2.toUpperCase();}else{return;}}else{return;}}else{return;}}}
There is a very substantial difference in the perf and allocation behavior of this generated code.
Note: with enough compiler optimizations in future, it might be possible to generate this directly from the code written using the PPX.
The text was updated successfully, but these errors were encountered:
Some mention should go in the README that the generated code is not comparable to the handwritten one, in terms of perf. So one should be aware of that.
The "alternative without the syntax sugar" in the README has a few typos. I believe it should be this:
The JS output:
So that's more or less (or perhaps exactly) the code produced by the ppx.
Consider instead this other handwritten version:
and the generated JS:
There is a very substantial difference in the perf and allocation behavior of this generated code.
Note: with enough compiler optimizations in future, it might be possible to generate this directly from the code written using the PPX.
The text was updated successfully, but these errors were encountered: