ndmitchell / ndmitchell/hlint

Avoid isJust/fromJust

Open
#156 5 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

From https://code.google.com/p/ndmitchell/issues/detail?id=238 by @np:

In most situations code like:

if null lst then ... else ... head l ... tail l ...

could be replaced by a case

case lst of [] -> ... ; x : xs -> ... x ... xs ...

Same thing with isJust + fromJust, but maybe could be suggested instead of a case.

@ndmitchell replies:

if isNothing x then 0 else fromJust x + 3

Should suggest:

maybe 0 (+3) x

This relies on having a nice looking functional in the else. Alternatively could have patterns with context, i.e.

if isNothing x then y else _f x ==> maybe x _f x

where _f is the lambda that needs inserting to get it working.

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 the issue's isNothing/fromJust examples and the proposed maybe transformation. Define which patterns should trigger a suggestion, including the case where the else branch needs a function, and verify that the resulting suggestion preserves the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.