SiriusStarr/elm-review-pipeline-styles/1.3.2

NOTE: the latest version is 1.3.9

ReviewPipelineStyles.Fixes

This module contains various PipelineFixs that can be used to fix failing pipelines.

Note that all fixes will only run if it is possible to fix the pipeline that way, i.e. that the fix will not generate invalid code.

Fixes

eliminatingInputStep : PipelineFix ApplicationPipeline

A fix that eliminates the input step of a pipeline by applying it directly to the next step, e.g.

a =
    foo |> bar |> baz

becomes

a =
    bar foo |> baz

Note that this fix will only be applied if the input step actually can be combined in this way. It is thus recommended that you combine it with ReviewPipelineStyles.Predicates.haveASimpleInputStep or the like.

makingMultiline : PipelineFix pipelineType

Force a pipeline to span a new line with each step. This will not run on pipelines that already span multiple lines. It is thus recommended that you combine it with a negated ReviewPipelineStyles.Predicates.spanMultipleLines or the like.

This fix (as with most) relies on elm-format to clean up the resulting code.

makingSingleLine : PipelineFix pipelineType

Force a pipeline onto a single line. This can only run on a very limited set of pipelines, due to the possibility of generating invalid code. Specifically, for this fix to run, all steps of a pipeline must consist of expressions on a single line and no comments may exist in the pipeline (as they would get clobbered by the fix). It will, of course, also not run on a pipeline that is already on a single line, so it is recommended that you combine it with ReviewPipelineStyles.Predicates.spanMultipleLines or the like.

convertingToRightPizza : PipelineFix ApplicationPipeline

Convert an application pipeline to right function application (|>). This requires there to be no internal comments (as they would be clobbered), to not already be a right function application pipeline, and to not be an immediate nested pipeline (as operator precedence rules preclude this).

convertingToLeftPizza : PipelineFix ApplicationPipeline

Convert an application pipeline to left function application (<|). This requires there to be no internal comments (as they would be clobbered), to not already be a left function application pipeline, and to not be an immediate nested pipeline (as operator precedence rules preclude this).

convertingToParentheticalApplication : PipelineFix ApplicationPipeline

Convert an application pipeline to parenthetical function application. This requires there to be no internal comments (as they would be clobbered) and to not already be a parenthetical function application pipeline.

convertingToRightComposition : PipelineFix CompositionPipeline

Convert a composition pipeline to right function composition (>>). This requires there to be no internal comments (as they would be clobbered), to not already be a right function composition pipeline, and to not be an immediate nested pipeline (as operator precedence rules preclude this).

convertingToLeftComposition : PipelineFix CompositionPipeline

Convert a composition pipeline to left function composition (<<). This requires there to be no internal comments (as they would be clobbered), to not already be a left function composition pipeline, and to not be an immediate nested pipeline (as operator precedence rules preclude this).

Custom Fixes

If you need fixes beyond what is provided above, you can create them manually by writing a function of type (Range -> String) -> Pipeline -> Maybe (List Fix) or ModuleNameLookupTable -> (Range -> String) -> Pipeline -> Maybe (List Fix) and using one of the functions below.

Use the functions in Getting Information About Pipelines to build your custom fix.

fix :
((Range -> String) -> Pipeline -> Maybe (List Fix))
-> PipelineFix pipelineType

Create a PipelineFix from a function that takes a source code extractor and a Pipeline and maybe returns a list of fixes. Needless to say, this is dangerous, as it is possible to generate invalid code if you are not careful.

If you think a generally useful fix is missing, please open an issue or PR on Github: https://github.com/SiriusStarr/elm-review-pipeline-styles/issues

( ModuleNameLookupTable
-> (Range -> String)
-> Pipeline
-> Maybe (List Fix)
)
-> PipelineFix pipelineType

Create a PipelineFix from a function that takes a ModuleNameLookupTable, source code extractor, and a Pipeline and maybe returns a list of fixes. Needless to say, this is dangerous, as it is possible to generate invalid code if you are not careful.

If you think a generally useful fix is missing, please open an issue or PR on Github: https://github.com/SiriusStarr/elm-review-pipeline-styles/issues

Types

These are exposed only for the sake of type annotations; you shouldn't need to work with them directly.

type alias PipelineFix pipelineType =
PipelineFix pipelineType

A means of fixing a pipeline, to (presumably) bring it stylistically inline with what is desired.