lue-bird/elm-review-single-use-type-vars-end-with-underscore/2.0.0

NOTE: the latest version is 2.0.4

elm-review-single-use-type-vars-end-with-underscore

elm-review rule to make sure that type variables which are only used once are highlighted with the suffix -_.

why does this exist?

-_ at the end of a type variable is a good indication that it is used only in this one place.

Some types have a lot of type variables, most of them only used once. If you see a -_

  • you know not to focus on these
  • through the review rule you can make sure that this type variable isn't used anywhere else → 2 type variables can't accidentally be the same.

example

Which one is easier to understand?

at :
    Nat (ArgIn indexMin minLengthMinus1 indexIfN)
    -> LinearDirection
    -> Arr (In (Nat1Plus minLengthMinus1) maxLength) element
    -> element

at :
    Nat (ArgIn indexMin_ minLengthMinus1 indexIfN_)
    -> LinearDirection
    -> Arr (In (Nat1Plus minLengthMinus1) maxLength_) element
    -> element

(from typesafe-array: Arr.at)

Once youre used to this, it can be really nice, similar to

at :
    Nat (ArgIn _ minLengthMinus1 _)
    -> LinearDirection
    -> Arr (In (Nat1Plus minLengthMinus1) _) element
    -> element

which sadly doesn't exist 😢

Provided rules

Configuration

module ReviewConfig exposing (config)

import OnlyAllSingleUseTypeVarsEndWith_
import Review.Rule exposing (Rule)

config : List Rule
config =
    [ OnlyAllSingleUseTypeVarsEndWith_.rule
    ]

Don't use this

When you already use the -_ suffix in (multi-use) type variables.