ndmitchell / ndmitchell/hlint

Prefer Map.member k to Maybe.isJust . Map.lookup k

Open
#882 6 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.