SchemaDSLModule

PackageReified.Schema
The concise schema-definition vocabulary: the record computation expression, its field and constructor forms, and the collection-schema operations.

Summary

NameSignatureSynopsis
Operations
schemaschema Record-schema computation expression.
casecase tagStarts one named-field union case.
tryExtracttryExtract tryPayloadSelects the union case and exposes its field payload.
fieldAsfieldAs name getterDeclares a field under an explicit wire name, for when the name differs from the property and for portable code.
constructconstruct constructorCloses a record schema with a total constructor.
constructResultconstructResult constructorCloses a record schema with a checked constructor.
constrainItemsconstrainItems constraint' schemaAdds a constraint to every item described by a list schema.
constrainValuesconstrainValues constraint' schemaAdds a constraint to every value described by a string-keyed map schema.

Operations

kind:member

schema

schema
Member
Record-schema computation expression.

Returns

SchemaBuilder<'model>
kind:member

case

case tag
Member
Starts one named-field union case.

Parameters

NameTypeDescription
tagstring

Returns

UnionCaseBuilder<'union, 'payload>

Verification Examples

let tryVolumeCase = function Volume amount -> Some amount | _ -> None

case "volume" {
    tryExtract tryVolumeCase
    fieldAs "amount" id
    construct Volume
}
kind:member

tryExtract

tryExtract tryPayload
Member
Selects the union case and exposes its field payload.

Parameters

NameTypeDescription
tryPayload'union -> 'payload option

Returns

UnionCaseExtraction<'union, 'payload>
kind:member

fieldAs

fieldAs name getter
Member
Declares a field under an explicit wire name, for when the name differs from the property and for portable code.

Parameters

NameTypeDescription
namestring
getter'model -> 'value

Returns

field<'model, 'value>

Verification Examples

type Signup = { Email: string }
 fieldAs "email_address" (fun (s: Signup) -> s.Email)
kind:member

construct

construct constructor
Member
Closes a record schema with a total constructor.

Parameters

NameTypeDescription
constructor'constructor

Returns

ConstructorStep<'model, 'constructor>
kind:member

constructResult

constructResult constructor
Member
Closes a record schema with a checked constructor.

Parameters

NameTypeDescription
constructor'constructor

Returns

CheckedConstructorStep<'model, 'constructor>
kind:member

constrainItems

constrainItems constraint' schema
Member
Adds a constraint to every item described by a list schema.

Parameters

NameTypeDescription
constraint'Constraint<'item>
schemaSchema<'item list>

Returns

Schema<'item list>

Verification Examples

Schema.list () |> constrainItems Constraint.present
kind:member

constrainValues

constrainValues constraint' schema
Member
Adds a constraint to every value described by a string-keyed map schema.

Parameters

NameTypeDescription
constraint'Constraint<'item>
schemaSchema<Map<string, 'item>>

Returns

Schema<Map<string, 'item>>

Verification Examples

Schema.map () |> constrainValues Constraint.present