This module can be use to codegen a set with a custom type as value.
Configuration used to build a generic set.
init : { valueType : Elm.Annotation.Annotation, namespace : List String, toComparable : Elm.Expression -> Elm.Expression } -> Config
Starts building a custom set, given the type of the value, the namespace of the resulting file, and a toComparable
function.
The toComparable
function will be copied in each declaration, so it should be kept very simple (or extracted to a function, and then passed in like { toComparable = Gen.YourType.toString }
, or similar).
withTypeName : String -> Config -> Config
Use a custom type name for the set type.
useElmFastDict : Config -> Config
Use miniBill/elm-fast-dict
as the backing container.
This means that generated code will depend on that package but gives the advantages of that package (read elm-fast-dict
's README for pros and cons).
generateFile : Config -> Elm.File
Generates a file from the given configuration.
generateDeclarations : Config -> List Elm.Declaration
Generates declarations from the given configuration.
This can be useful if you want to add your own custom declarations to the file.