miniBill/elm-generic-dict/1.0.2

NOTE: the latest version is 1.1.0

GenericDict

This module can be use to codegen a dictionary with a custom type as key.

Types

type Config

Configuration used to build a generic dictionary.

Configuration

{ keyType : Annotation
, namespace : List String
, toComparable : Expression -> Expression
}
-> Config

Starts building a custom dictionary, given the type of the key, 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 dictionary type.

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).

Generation

Generates a file from the given configuration.

generateDeclarations : Config -> List Declaration

Generates declarations from the given configuration.

This can be useful if you want to add your own custom declarations to the file.