Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Start removing let%foo #87

Merged
merged 1 commit into from
Apr 6, 2021
Merged

Start removing let%foo #87

merged 1 commit into from
Apr 6, 2021

Conversation

chenglou
Copy link
Member

@chenglou chenglou commented Apr 6, 2021

  • The let%try and others ended up swallowing lots of important production errors (surprise... =/)
  • Related: it discourages proper error handling. Consider that across ~210 callsites that can be handled with let%foo, ~150 of them were (and thus swallowed the error), and only 60 stayed as switch. It's not possible that only 28% needed proper error handling. This explains our previous point.
  • The transforms in their current state don't give an error message location (partially due to usage of metaquot. Meta yak shaving).
  • This makes the build depend on OMP, ppxlib and others. Giant deps, giant build times.
  • But seriously, if even Cristiano has problem writing proper option and result handling in production because of let% stuff then what chance do most others have.

Anyway I'm gonna remove it because this seems to be a blocker for cleaning up the codebase's other parts...

First step is to build the same monad ppx as an executable; I'll directly run this through the source files using unmonad.sh, print them back to Reason syntax, and manually clean up some stuff.

See #86, which is converted by the script. Using the ppx script itself ensures that we don't cause conversion bugs.

After this PR, I'm thinking of directly making the ppx transform the let% stuff into regular switch statements, and print out those.

- The let%try and others ended up swallowing lots of important production errors (surprise... =/)
- The transforms in their current state don't give an error message location (partially due to usage of metaquot. Meta yak shaving).
- This makes the build depend on OMP, ppxlib and others. Giant deps, giant build times.
- But seriously, if even Cristiano has problem writing proper option and result handling in production because of `let%` stuff then what chance do most others have.

Anyway I'm gonna remove it because this seems to be a blocker for cleaning up the codebase's other parts...

First step is to build the same monad ppx as an executable; I'll directly run this through the source files using `unmonad.sh`, print them back to Reason syntax, and manually clean up some stuff.

See #86, which is converted by the script. Using the ppx script itself ensures that we don't cause conversion bugs.

After this PR, I'm thinking of directly making the ppx transform the `let%` stuff into regular switch statements, and print out those.
@chenglou
Copy link
Member Author

chenglou commented Apr 6, 2021

Merging. No bug since this is additive

@chenglou chenglou merged commit 5261974 into master Apr 6, 2021
@chenglou chenglou deleted the unmonad branch April 6, 2021 23:31
@cristianoc
Copy link
Contributor

@chenglou there are a lot of warnings like this when building:

Warning 3: deprecated: module Ast_406
Access modules via the Migrate_parsetree toplevel module. Use Migrate_parsetree.Ast_406 instead.

I guess that's just temporary during the removal.

@cristianoc
Copy link
Contributor

Oh they were all coming from that file. Just silenced the warnings for ppx2 in master.

chenglou added a commit that referenced this pull request Apr 7, 2021
Follow-up of #87

Now we can properly add error handling to these `None`/`Error(_)` later
chenglou added a commit that referenced this pull request Apr 7, 2021
* Make the unmonad script turn the let% into `switch` instead

Follow-up of #87

Now we can properly add error handling to these `None`/`Error(_)` later

* Check in the tests on 2 files

Supercedes #86
chenglou added a commit that referenced this pull request Apr 7, 2021
chenglou added a commit that referenced this pull request Apr 7, 2021
chenglou added a commit to chenglou/rescript-editor-support that referenced this pull request Apr 24, 2021
- The let%try and others ended up swallowing lots of important production errors (surprise... =/)
- The transforms in their current state don't give an error message location (partially due to usage of metaquot. Meta yak shaving).
- This makes the build depend on OMP, ppxlib and others. Giant deps, giant build times.
- But seriously, if even Cristiano has problem writing proper option and result handling in production because of `let%` stuff then what chance do most others have.

Anyway I'm gonna remove it because this seems to be a blocker for cleaning up the codebase's other parts...

First step is to build the same monad ppx as an executable; I'll directly run this through the source files using `unmonad.sh`, print them back to Reason syntax, and manually clean up some stuff.

See rescript-lang#86, which is converted by the script. Using the ppx script itself ensures that we don't cause conversion bugs.

After this PR, I'm thinking of directly making the ppx transform the `let%` stuff into regular switch statements, and print out those.
chenglou added a commit to chenglou/rescript-editor-support that referenced this pull request Apr 24, 2021
…-lang#89)

* Make the unmonad script turn the let% into `switch` instead

Follow-up of rescript-lang#87

Now we can properly add error handling to these `None`/`Error(_)` later

* Check in the tests on 2 files

Supercedes rescript-lang#86
chenglou added a commit to chenglou/rescript-editor-support that referenced this pull request Apr 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants