-
Notifications
You must be signed in to change notification settings - Fork 203
Warn when functions are unnecessarily monadic #1490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn when functions are unnecessarily monadic #1490
Conversation
9acdb90 to
1eb12bd
Compare
shayne-fletcher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very cool. lgtm.
1eb12bd to
80a294d
Compare
|
How does this do with something that isn't monadic but uses e.g. these examples {-# LANGUAGE BlockArguments #-}
x =
(+)
do 3 + 5
do 4 * 7
y = do
let z = 5
z
f bla do
g x y zI would really like to get warnings on none of these, personally, because they are quite useful in specific cases. |
|
That's awesome, thanks! |
I am pleased to report that none of these examples emit a warning. I have added them as test cases (4b8904e). The rule is pretty conservative, and only triggers when |
4b8904e to
2a5ec92
Compare
2a5ec92 to
e4ad48e
Compare
1eda112 to
af40db1
Compare
shayne-fletcher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @ndmitchell
|
on f x = do
pure xwe get the ideal i guess would be not a blocker i would suppose but is that within reach? |
The type signature of |
|
let's land this. we can always work in-situ if neil comes back with suggestions later. |
|
Thanks for the patch, and thanks Shayne for merging. I didn't notice this, and have unfortunately not been paying attention for a bit too long 😞 . Afraid I don't think this can work as an HLint hint. Firstly, there is a bug, in that if you have: This reports that The other issue is that there isn't a good "fix" for this, as doing so necessarily changes the signature, and thus you have to update all callers. No other HLint hints have that property, and I'm not sure if it's something we want to start or not. I guess we could have it as an off by default hint, but it still does things that HLint otherwise doesn't ever do, so I'm not sure it fits. Sorry for the effort you two invested in this. |
Closes #832