ndmitchell / hlint

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

Correct Functor law hint #1540

Closed MatthijsBlom closed 10 months ago

MatthijsBlom commented 1 year ago

<$> associates to the left, so f <$> g <$> x is equivalent to f . g <$> x not because of a Functor law, but because for functions (<$>) == (.).

The actual Functor law was missing, so I added it.

The original hint could perhaps be generalized to f <$> gf . g, but I could not figure out how to express that g should be a function.

googleson78 commented 1 year ago

The original hint could perhaps be generalized to f <$> g ↦ f . g, but I could not figure out how to express that g should be a function.

You almost certainly can't in the general case, because hlint only does parsing, no typechecking.

ndmitchell commented 10 months ago

Thanks!