module yeti.lang.compiler.showtype

Yeti type formatting interface.

typedef typeitem<t1> = {
description is string,
Description of the member (from the YetiDoc comment in code).
mutable is boolean,
Whether the member is a mutable field?
name is string,
Name of the member (either field name or variant tag name).
tag is string,
Tag of the type.

"." - member is expected by code using the value

"`" - member is both used in code and provided by a constructor
type is t1
Type of the member.
}

typedef type = ('a is
Alias {
alias is string,
The name of type variable being alias to the type.
type is 'a
The actual type. The alias may occur as Simple type inside it.
} |
Alias definition, used on recursive type definitions.
Function list<'a> |
Function type, the last element in the list is return type.

If there are more than 2 elements, it represents a curried function type with multiple arguments.
Parametric {
params is list<'a>,
Type parameters for the parametric type.
type is string
The name of the parametric type (for example "list").
} |
Parametric type like map, list or alias created by typedef declaration.

Examples

Yeti type list<number> would be represented as:
 Parametric { type = "list", params = [Simple "number"] }
Simple string |
Primitive type (like number, string etc) or type variable.
Struct list<typeitem<'a>> |
Struct (record) type, parameter is a list of fields.
Variant list<typeitem<'a>>
Variant type, parameter is a list of variants.
)

typedef showType_fun = string → type → string

typedef showType_param =
CommentDoc () |
Whether YetiDoc comments should be included in the formatted type.
FormatDoc (string → string → string) |
Function for formatting YetiDoc comments associated with member types.
Indent string |
Indention step string used when formatting the type.
ShowType showType_fun
Function used to get string representation of component types (type parameters, member types, function argument return types etc).

This is used for example by the YetiDoc HTML generator together with CommentDoc option.

Module signature

{
showType options indent type is list<showType_param> → showType_fun
Formats the given type into string representation according to the formatting options. The type(s) can be obtained from Yeti code using the yeti.lang.compiler.eval module functions.
options-formatting options (look the showType_param typedef)
indent-initial indent string (to be included at each new line start)
type-the type to be formatted
}