hlint icon indicating copy to clipboard operation
hlint copied to clipboard

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

Open googleson78 opened this issue 2 years ago • 3 comments
trafficstars

googleson78 avatar Oct 06 '23 08:10 googleson78

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

ndmitchell avatar Oct 15 '23 14:10 ndmitchell

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?

googleson78 avatar Nov 07 '23 13:11 googleson78

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.

ndmitchell avatar Jan 14 '24 17:01 ndmitchell