Repository F# setup
open Reified
open Reified.Refinements
open Reified.Result
open Reified.Schema.Json

Derived Schemas

[<DeriveSchema>] removes the mechanical duplication between a wire record and its Schema<_> declaration. The build reads ordinary F# source, infers a schema from each marked record, and generates normal constructor-last Schema DSL code before F# compilation.

namespace MyApp.Wire

open Reified.DerivedSchema

[<DeriveSchema>]
type Signup =
    { [<Email; Present>]
      Email: string
      [<AtLeast 18>]
      Age: int
      Tags: string list }

The generated companion module provides:

Signup.schema    // Schema<Signup>
Signup.parse     // Data -> Result<Signup, SchemaErrors>
Signup.validate  // Signup -> Result<Signup, SchemaErrors>

This is source generation, not runtime reflection. The attributes are inert metadata; the generated F# uses the same Schema DSL as a hand-written declaration and therefore works with parsing, inspection, JSON codecs, JSON Schema, NativeAOT, trimming, and Fable.

Guides

When to derive

Derivation is intended for public, permissive boundary records. Keep domain invariants in refined values or private domain types, then map the parsed wire record through a domain constructor. See Separate Wire and Domain Models.