Skip to content
Louis Kueh edited this page Nov 6, 2018 · 12 revisions

The general syntax is lhs -- rhs with lhs being the expression you expect to be rewritten as rhs.

The absence of rhs means you expect no hints to fire. In addition ??? lets you assert a warning without a particular suggestion, while @ tags require a specific severity -- both these features are used less commonly.

Haskel - HLint Github

HLint source hints

Guidelines

  • Improve code and teach author better style. Doing modifications one by one individually improves style.

  • Display semantically changing hints

  • Severity

    • Error - parse error
    • warning - concat (map f x ) => concatMap f x
    • suggestion - worthwhile but not to be applied blindly
  • Ignore/suppress hints based on user input, as hints do not always make sense

misc hints

  • bracket reduction only (e.g. (foo) => foo)
  • imports => import A(B); import A(C) = import A(B,C)

lambda

Concept: Remove all the lambdas you can be inserting only sections Never create a right section with +-# as the operator (they are misparsed) Rules:

    fun a = \x -> y  -- promote lambdas, provided no where's outside the lambda
    fun x = y x  -- eta reduce, x /= mr and foo /= symbol
    \x -> y x  -- eta reduce
    ((#) x) ==> (x #)  -- rotate operators
    (flip op x) ==> (`op` x)  -- rotate operators
    \x y -> x + y ==> (+)  -- insert operator
    \x y -> op y x ==> flip op
    \x -> x + y ==> (+ y)  -- insert section,
    \x -> op x y ==> (`op` y)  -- insert section
    \x -> y + x ==> (y +)  -- insert section
    \x -> \y -> ... ==> \x y -- lambda compression
    \x -> (x +) ==> (+) -- operator reduction

Clone this wiki locally