Elex.Labels (Elex v0.3.0)

View Source

Provides human-readable labels for expression types.

Used by Elex.Validator and Elex.Evaluator when formatting type error messages.

This module can be extended by applications to provide localized labels using Gettext.

Supported types

TypeLabel
:decimal"number"
:string"text"
:boolean"yes/no"
nil"empty"
:unknown"value"

Summary

Functions

Formats a got … clause for function type errors.

Returns a human-readable label for an expression type.

Functions

got(type)

Formats a got … clause for function type errors.

Primitive types stay got decimal. Category atoms become got length quantity so length(1m) is not read as a tautology.

Examples

got(:decimal)
#=> "got decimal"

got(:length)
#=> "got length quantity"

label(dim)

Returns a human-readable label for an expression type.

Can be overridden in applications that use Gettext for localization.

Parameters

  • type - An expression type atom (:decimal, :string, :boolean, or :unknown)

Returns

A short human-readable label string.

Examples

label(:decimal)
#=> "number"

label(:boolean)
#=> "yes/no"