mu-schema-0.3.1.2: Format-independent schemas for serialization
Safe HaskellNone
LanguageHaskell2010

Mu.Schema.Registry

Description

A registry of schemas saves the different schemas supported by an application. Since messages and protocols may evolve, it's useful to keep an updated view of the different shapes of data we can handle.

Examples of registries are found in Kafka and Compendium.

Synopsis

Registry of schemas

type Registry = Mappings Nat Schema' Source #

A Registry is defined as a map from version numbers to type-level schemas.

Implementation note: you must write newer schemas at the head of the Registry. Otherwise, older schemas take precedence during conversion.

fromRegistry :: forall r t. FromRegistry r t => Term -> Maybe t Source #

Converts a schemaless term into a value by checking all the possible schemas in a Registry.

Implementation note: schemas are checked in the same order in which they appear in the Registry definition.

Terms without an associated schema

data Term where Source #

Interpretation of a type in a schema.

Constructors

TRecord :: [Field] -> Term

A record given by the value of its fields.

TEnum :: Int -> Term

An enumeration given by one choice.

TSimple :: FieldValue -> Term

A primitive value.

Instances

Instances details
Eq Term Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

(==) :: Term -> Term -> Bool #

(/=) :: Term -> Term -> Bool #

Ord Term Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

compare :: Term -> Term -> Ordering #

(<) :: Term -> Term -> Bool #

(<=) :: Term -> Term -> Bool #

(>) :: Term -> Term -> Bool #

(>=) :: Term -> Term -> Bool #

max :: Term -> Term -> Term #

min :: Term -> Term -> Term #

Show Term Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

showsPrec :: Int -> Term -> ShowS #

show :: Term -> String #

showList :: [Term] -> ShowS #

data Field where Source #

Interpretation of a field.

Constructors

Field :: Text -> FieldValue -> Field

A single field given by its name and its value.

Instances

Instances details
Eq Field Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

(==) :: Field -> Field -> Bool #

(/=) :: Field -> Field -> Bool #

Ord Field Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

compare :: Field -> Field -> Ordering #

(<) :: Field -> Field -> Bool #

(<=) :: Field -> Field -> Bool #

(>) :: Field -> Field -> Bool #

(>=) :: Field -> Field -> Bool #

max :: Field -> Field -> Field #

min :: Field -> Field -> Field #

Show Field Source # 
Instance details

Defined in Mu.Schema.Interpretation.Schemaless

Methods

showsPrec :: Int -> Field -> ShowS #

show :: Field -> String #

showList :: [Field] -> ShowS #

data FieldValue where Source #

Interpretation of a field type, by giving a value of that type.