jxxcarlson/elm-review-codeinstaller/13.0.0

Install.Function.InsertFunction

Add a function in a given module if it is not present.

-- code for ReviewConfig.elm:
rule =
    Install.Function.InsertFunction.config
        "Frontend"
        "view"
        """view model =
        Html.text "This is a test\""""
        |> Install.insertFunction

Running this rule will insert the function view in the module Frontend with the provided implementation.

The form of the rule is the same for nested modules:

rule =
    Install.Function.InsertFunction.config
        "Foo.Bar"
        "earnInterest"
        "hoho model = { model | interest = 1.03 * model.interest }"
        |> Install.insertFunction
config : String -> String -> String -> Config

Initialize the configuration for the rule.

type alias Config =
Config

Configuration for rule: add a function in a specified module if it does not already exist.

withInsertAfter : String -> Config -> Config

Add the function after a specified declaration. Just give the name of a function, type, type alias or port and the function will be added after that declaration. Only work if the function is being added and not replaced.