stil4m / elm-syntax / Elm.Interface

A type that represents the interface for an Elm module. You can see this as a trimmed down version of a file that only contains the header (module X exposing (..)) and some small set of additional data.

Types


type alias Interface =
List Exposed

An interface is just a list of 'things' that are exposed by a module.

[ Type "Color" [ "Red", "Blue" ], Function "asRgb" ]


type Exposed
    = Function String
    | CustomType (( String, List String ))
    | Alias String
    | Operator Elm.Syntax.Infix.Infix

Union type for the things that a module can expose. These are Functions, CustomTypes, and Aliases.

Elm core packages can also define Operators, and thus we take that into account as well. The Infix type alias will contain all the information regarding the operator

Functions

build : Elm.RawFile.RawFile -> Interface

Build an interface from a file

exposesAlias : String -> Interface -> Basics.Bool

A function to check whether an Interface exposes an certain type alias.

exposesFunction : String -> Interface -> Basics.Bool

Check whether an Interface exposes an function.

exposesFunction "A" [ Function "A", CustomType "B", [ "C" ] ] == True
exposesFunction "B" [ Function "A", CustomType "B", [ "C" ] ] == False
exposesFunction "<" [ Infix { operator = "<" , ... } ] == True
exposesFunction "A" [ Alias "A" ] == False

operators : Interface -> List Elm.Syntax.Infix.Infix

Retrieve all operators exposed by the Interface