jxxcarlson/elm-review-codeinstaller/13.0.0

Install.Import

Add import statements to a given module. For example, to add import Foo.Bar to the Frontend module, you can use the following configuration:

Install.Rule.rule
    [ Install.Import.config "Frontend"
        [ Install.Import.module_ "Foo.Bar" ]
        |> Install.Rule.addImport
    ]

To add the statement import Foo.Bar as FB exposing (a, b, c) to the Frontend module, do this:

Install.Import.config "Frontend"
    [ Install.Import.module_ "Foo.Bar"
        |> Install.Import.withAlias "FB"
        |> Install.Import.withExposedValues [ "a", "b", "c" ]
    ]

There is a shortcut for importing modules with no alias or exposed values

Install.Import.qualified "Frontend"
    [ "Foo.Bar", "Baz.Qux" ]
String
-> List
{ moduleToImport : String
, alias : Maybe String
, exposedValues : Maybe (List String)
}
-> Config

Initialize the configuration for the rule.

type alias Config =
Config

Configuration for the rule.

type alias ImportData =
{ moduleToImport : String
, alias : Maybe String
, exposedValues : Maybe (List String)
}

The functions config and module_ returns values of this type; The functions withAlias and withExposedValues transform values of this type.

module_ : String -> ImportData

Create a module to import with no alias or exposed values

withAlias : String -> ImportData -> ImportData

Add an alias to a module to import

withExposedValues : List String -> ImportData -> ImportData

Add exposed values to a module to import

qualified : String -> List String -> Config

Create a rule that adds import statements to a module with no alias or exposed values. Just pass the module name and the list of modules to import.