ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Wire

Description

A table-driven codec for the small named-enum vocabularies the system speaks: the ecosystem key, the log format and level, and the telemetry switch. A WireVocab instance carries one (value, name) table plus the human noun for the set. lookupWire, parseWire and renderWire all read that table, so a parse, a render, and the accepted-set message cannot drift apart.

The vocabulary keys on the type, so each type speaks exactly one vocabulary.

Synopsis

Documentation

class WireVocab a where Source #

The wire vocabulary of a named-enum type. The (value, name) table is the single source of truth for the codec.

Minimal complete definition

wireKind, wireTable

Methods

wireKind :: Text Source #

The human noun for the vocabulary, e.g. "log format". Names the accepted set in parseWires failure message.

wireTable :: NonEmpty (a, Text) Source #

Every value paired with its canonical wire name, in the order the accepted-set message names them. It must list every inhabitant, because renderWire reads from it.

wireAliases :: [(a, Text)] Source #

Further spellings lookupWire accepts. An alias never reaches the accepted-set message, and renderWire never emits one. Empty by default.

Instances

Instances details
WireVocab Ecosystem Source # 
Instance details

Defined in Ecluse.Core.Ecosystem

lookupWire :: WireVocab a => Text -> Maybe a Source #

The value a wire name denotes, through wireTable and then wireAliases. Nothing for a name in neither.

parseWire :: WireVocab a => Text -> Either Text a Source #

Parse a wire name, or report the accepted set on an unrecognised input. The message is unknown \kind\ "\raw\" (expected one of: \names\), with the names in table order.

renderWire :: (WireVocab a, Eq a) => a -> Text Source #

The canonical wire name of a value, read out of the wireTable. It is total, so the class contract that the table lists every inhabitant is what keeps it correct.