Refactor TcRnMonad.mapAndRecoverM
ClosedPublic

Authored by sjakobi on Nov 16 2018, 8:31 AM.

Details

Summary

This version doesn't require the 'reverse' step after the monadic
fold.

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sjakobi created this revision.Nov 16 2018, 8:31 AM

Maybe you could use mapMaybeM instead of a fold?

sjakobi updated this revision to Diff 18709.Nov 16 2018, 2:53 PM
  • Improve TcRnMonad.mapAndRecoverM a bit
  • Define mapAndRecoverM via mapMaybeM

Maybe you could use mapMaybeM instead of a fold?

Good idea! :)

tdammers accepted this revision.Nov 19 2018, 8:08 AM
This revision is now accepted and ready to land.Nov 19 2018, 8:08 AM

I'd slightly prefer not using LambdaCase (rightToMaybe (Left _) = ...) for consistency, but this is a small detail.

sjakobi updated this revision to Diff 18778.Nov 19 2018, 3:41 PM
  • Don't use LambdaCase for rightToMaybe
This revision was automatically updated to reflect the committed changes.