Compute visitors only once for a given input

This commit is contained in:
Jeroen Engels 2017-01-08 10:58:45 +01:00
parent 3c27a18207
commit a491c97059
2 changed files with 12 additions and 7 deletions

View File

@ -93,12 +93,9 @@ statementToVisitors node =
[]
lint : List Statement -> LintRule context -> List Error
lint statements rule =
lintWithVisitors : List (Visitor context) -> LintRule context -> List Error
lintWithVisitors visitors rule =
let
visitors =
List.concatMap statementToVisitors statements
( errors, _ ) =
List.foldl
(\visitor ( errors, ctx ) ->
@ -112,3 +109,8 @@ lint statements rule =
visitors
in
errors
lint : List Statement -> LintRule context -> List Error
lint statements =
lintWithVisitors (List.concatMap statementToVisitors statements)

View File

@ -100,10 +100,13 @@ lint ast =
|> Result.map (\( _, _, statements ) -> statements)
|> Result.withDefault []
lint =
Lint.lint statements
errors =
List.concat
[ Lint.lint statements FindNoAnnotatedFunction.rule
, Lint.lint statements NoDebug.rule
[ lint FindNoAnnotatedFunction.rule
, lint NoDebug.rule
]
in
div [] (List.map (\x -> p [] [ text x ]) errors)