Prefer Map.member k to Maybe.isJust . Map.lookup k
Open
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 1.6k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
I think this would be good to have in the default hlint config.
If not, I'd like help getting the rule to work for this code:
> import qualified Data.Maybe as Maybe
> import qualified Data.Map as Map
> -- given this code
> Maybe.isJust $ Map.lookup 1 (Map.fromList [(1,True)])
True
> -- want to recommend
> Map.member 1 (Map.fromList [(1,True)])
True
Here is what I tried as an hlint rule with HLint v2.2.11:
- error:
name: Prefer Map.member k to Maybe.isJust . Map.lookup k
lhs: Data.Maybe.isJust . Data.Map.lookup k
rhs: Data.Map.member k
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing HLint's default configuration and custom rule syntax, using the issue's Map.lookup and Maybe.isJust example as the reproduction. Determine whether the requested suggestion can be expressed and enabled by default; done means the example recommends Map.member with the intended equivalent result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100