What's the way to match the following code-pattern...
do
x <- createModel a b
case x of
Left e -> throwM $ ValidationErrors e
Right y -> ...
...and suggest the following replacement:
withThrow $ createModel a b
I tried the following, but it doesn't work:
hint: {lhs: "do {x <- createModel v w; case x of Left e -> throwM $ ValidationErrors e}", rhs: "withThrow $ createModel v w"}
The problem is that HLint matching is expression based, whereas the rule you're trying to define is really statement based - you want to match the two statements anywhere adjacently in a
do
. It's possible HLint could be modified to do that, and you think that would be useful, please raise an HLint issue.