{"id":17771282,"url":"https://github.com/lue-bird/elm-review-equals-caseable","last_synced_at":"2026-07-02T20:02:24.641Z","repository":{"id":182415412,"uuid":"668459851","full_name":"lue-bird/elm-review-equals-caseable","owner":"lue-bird","description":"elm-review: report `==` when equivalent `case of` exists","archived":false,"fork":false,"pushed_at":"2023-07-21T11:00:04.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T08:47:58.168Z","etag":null,"topics":["case-of","elm","elm-review","equal","if","match"],"latest_commit_sha":null,"homepage":"https://dark.elm.dmy.fr/packages/lue-bird/elm-review-equals-caseable/latest/","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lue-bird.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-19T21:31:01.000Z","updated_at":"2023-07-19T21:32:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"c608a5cb-9df1-404a-997b-d258c3c93078","html_url":"https://github.com/lue-bird/elm-review-equals-caseable","commit_stats":null,"previous_names":["lue-bird/elm-review-equals-caseable"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-review-equals-caseable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-review-equals-caseable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-review-equals-caseable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-review-equals-caseable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lue-bird","download_url":"https://codeload.github.com/lue-bird/elm-review-equals-caseable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246660077,"owners_count":20813338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["case-of","elm","elm-review","equal","if","match"],"created_at":"2024-10-26T21:31:17.257Z","updated_at":"2025-10-28T18:08:29.742Z","avatar_url":"https://github.com/lue-bird.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [elm-review-equals-caseable](https://dark.elm.dmy.fr/packages/lue-bird/elm-review-equals-caseable/latest/)\n\nProvides the [`elm-review`](https://package.elm-lang.org/packages/jfmengels/elm-review/latest/) rule [🔧`EqualsCaseable.forbid`](https://package.elm-lang.org/packages/lue-bird/elm-review-equals-caseable/1.0.0/EqualsCaseable#forbid) which reports when `==` is used but there's an equivalent `case of` available.\n\n## reported\n```elm\na =\n    if list == [] then\n        \"empty\"\n\n    else\n        \"filled\"\n```\n\n## not reported\n```elm\na =\n    case list of\n        [] -\u003e\n            \"empty\"\n\n        _ :: _ -\u003e\n            \"filled\"\n```\n\n## why\n\nReasons are pretty similar to [`VariablesBetweenCaseOf.AccessInCases.forbid`](https://dark.elm.dmy.fr/packages/lue-bird/elm-review-variables-between-case-of-access-in-cases/latest/#why).\nLet me highlight the most important ones:\n\n(Note: The exhaustiveness benefits shown are possible once [`NoWildcard`](https://github.com/jfmengels/elm-review/discussions/91) is implemented.)\n\n### notifies you when adding a new variant\n\n```elm\ntype Role\n    = Admin\n    | User\n\ncanBanUser =\n    \\theUserWhoTriesToBan -\u003e theUserWhoTriesToBan.role == Admin\n```\nIt's a new day and time for a new feature: moderators!\n```elm\ntype Role\n    = Admin\n    | Moderator\n    | User\n```\n\u003e It compiles, so it works! Time for a break.\n\n☕\n\n\u003e Oh crap! It don't work I'm sad elm has failed me I'm going back to typescript.\n\nOh no, you made them sad.\n\nWith the rules enabled:\n\n```elm\ntype Role\n    = Admin\n    | User\n\ncanBanUser =\n    \\theUserWhoTriesToBan -\u003e theUserWhoTriesToBan.role == Admin\n```\n→ `EqualsCaseable.forbid Everywhere` fixes to\n```elm\ncanBanUser =\n    \\theUserWhoTriesToBan -\u003e\n        case theUserWhoTriesToBan.role of\n            Admin -\u003e\n                True\n\n            _ -\u003e\n                False\n```\n→ `NoWildcard.rule` fixes to\n```elm\ncanBanUser =\n    \\theUserWhoTriesToBan -\u003e\n        case theUserWhoTriesToBan.role of\n            Admin -\u003e\n                True\n\n            User -\u003e\n                False\n```\nNow if you add moderator, elm will show you where there's more to handle specifically for moderators. Or as a quote by @janiczek on slack\n\u003e Now the compiler will tell me all the places I need to make a new decision\n\n\n### gives the compiler as much information as you have\nHere's [a real example](https://github.com/dillonkearns/elm-pages/blob/9d6d30235f7db8d3c2c0b40d78f3cc5a6278562d/src/Pages/Internal/RoutePattern.elm#L418)\n```elm\ntoVariant pattern =\n    if ... pattern.ending == Nothing then\n        Elm.variant \"Index\"\n\n    else\n        let\n            allSegments =\n                ...\n                    ++ ([ Maybe.map endingToVariantName pattern.ending\n                        ]\n                            |\u003e List.filterMap identity\n                       )\n        in\n        ...\n```\nDon't do this to yourself. Let the compiler know as much as you about the path you're in.\n```elm\ntoVariant pattern =\n    case pattern.ending of\n        Nothing -\u003e\n            Elm.variant \"Index\"\n\n        Just patternEnding -\u003e\n            let\n                allSegments =\n                    ... ++ [ endingToVariantName patternEnding ]\n            in\n            ...\n```\n\n### doesn't make you jump around\nHere's [a real example](https://github.com/dillonkearns/elm-pages/blob/9d6d30235f7db8d3c2c0b40d78f3cc5a6278562d/src/Pages/Internal/Platform.elm#L941)\n```elm\nif fields.method == Form.Get then\n    model.key\n        |\u003e Maybe.map\n            (\\key -\u003e\n                Browser.Navigation.pushUrl key\n                    (appendFormQueryParams fields)\n            )\n        |\u003e Maybe.withDefault\n            Cmd.none\n\nelse\n    -- wait, ... What is else?\n    let\n        urlToSubmitTo : Url\n        urlToSubmitTo =\n            model.url\n    in\n    fetchRouteData -1\n        (UpdateCacheAndUrlNew False model.url Nothing)\n        config\n        urlToSubmitTo\n        (Just fields)\n```\nbe explicit :)\n```elm\ncase fields.method of\n    Form.Get -\u003e\n        model.key\n            |\u003e Maybe.map\n                (\\key -\u003e\n                    Browser.Navigation.pushUrl key\n                        (appendFormQueryParams fields)\n                )\n            |\u003e Maybe.withDefault\n                Cmd.none\n\n    Form.Post -\u003e\n        let\n            urlToSubmitTo : Url\n            urlToSubmitTo =\n                model.url\n        in\n        fetchRouteData -1\n            (UpdateCacheAndUrlNew False model.url Nothing)\n            config\n            urlToSubmitTo\n            (Just fields)\n```\n\n\n## try it out\n\nYou can try the example configuration above out by running the following command:\n\n```bash\nelm-review --template lue-bird/elm-review-equals-caseable/example\n```\n\n## configure\n\n```elm\nmodule ReviewConfig exposing (config)\n\nimport EqualsCaseable\nimport Review.Rule exposing (Rule)\n\nconfig : List Rule\nconfig =\n    [ EqualsCaseable.forbid EqualsCaseable.InIf\n    ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-review-equals-caseable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flue-bird%2Felm-review-equals-caseable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-review-equals-caseable/lists"}