Skip to content
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

Add hints for when 'x <*> y' could be 'y' #1617

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

ysangkok
Copy link
Contributor

I haven't added all the alternatives with mempty and empty as hlint doesn't
know about types, and there could be lawless instances out there I suppose. So
it's safer just to deal with concrete types.

ghci> :{
ghci| let f :: Applicative m => m (b -> (Int, b))
ghci|     f = (,) <$> pure 5
ghci| :}
ghci> f <*> mempty :: Ap [] (Int, Sum Int)
Ap {getAp = [(5,Sum {getSum = 0})]}
ghci> f <*> empty :: Ap [] (Int, Sum Int)
Ap {getAp = []}

Would be nice to detect the last one, but hlint can't know that it's empty on Ap [] (..., Sum ...).

@ndmitchell ndmitchell merged commit 6035a13 into ndmitchell:master Oct 20, 2024
0 of 5 checks passed
@ndmitchell
Copy link
Owner

Thanks!

@ysangkok ysangkok deleted the applicative-rhs branch October 21, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants