ndmitchell / hlint

Haskell source code suggestions
Other
1.48k stars 195 forks source link

Add hints for replacing some `maybe` usage with equivalent `traverse` #1543

Open googleson78 opened 1 year ago

ndmitchell commented 1 year ago

Why is this desirable? The maybe function is more targeted so helps enforce types better.

googleson78 commented 1 year ago

I personally find it desirable because the maybe usage is essentially reimplementing traverse, i.e. this is exactly the implementation of traverse.

I do agree that type inference is worse with this hint, and potentially (although I'm not sure when), this might cause ambiguity errors. Perhaps some optional group might be better here?

ndmitchell commented 10 months ago

Definitely not in base, which in general doesn't do generalization. But further down there is a set of hints called generalised, where maybe to traverse would fit nicely. Happy to take the patch if adjusted to go there.