hlint icon indicating copy to clipboard operation
hlint copied to clipboard

Have lhs/rhs match rules apply to types as well as expressions

Open vrom911 opened this issue 7 years ago • 4 comments

I have file:

import Universum

import Control.Monad.Except (ExceptT)

foo :: ExceptT e m a
foo = undefined

and .hlint.yaml:

- warn: { name: "Use 'ExceptT' from Universum"
        , lhs: Control.Monad.Except.ExceptT, rhs: Universum.ExceptT }

I expect hlint to tell me that I should use ExceptT from Universum as I wrote in the rules, but

$ hlint example.hs 
No hints

I'm using hlint v2.0.11.

vrom911 avatar Feb 26 '18 15:02 vrom911

The language of expressions is really about replacing expressions, not types... I guess a subset of expressions are also valid types, and ditto patterns, so I could extend the pattern/types matcher to match on them too...

ndmitchell avatar Mar 06 '18 11:03 ndmitchell

Here's another example of a very useful type hint which I'd like to have:

- warn: {lhs: a => b => c, rhs: (a, b) => c}

yairchu avatar Jul 18 '19 11:07 yairchu

I think it's entirely reasonable that the {lhs: a => b => c, rhs: (a, b) => c} rule could be added as a custom rule to the internals of HLint (patch welcome!). The ExceptT one needs to have the more general mechanism though.

ndmitchell avatar May 02 '20 23:05 ndmitchell

We'd also like this feature, primarily so we can ban Handler Value in our app and require using more specific return types. I will see if I can get some cycles devoted to it.

parsonsmatt avatar Mar 19 '22 00:03 parsonsmatt