Myriad
A code generation and meta-programming tool for F#.
Myriad is a code generation and meta-programming tool for F#, built to make compile-time codegen a first-class, idiomatic part of the language rather than a workaround.
F# doesn’t have macros, and Type Providers solve a narrower problem than general-purpose code generation. Myriad fills that gap: annotate a type, point it at a plugin, and it emits real F# (discriminated unions, records, lenses), generated before compilation and optimized like everything else. No reflection at runtime, nothing at the type level you can’t inspect.
It ships with three plugins out of the box: fields (inspired by OCaml’s ppx_fields_conv), lenses (functional getter/setter pairs), and DuCases (toString/fromString/toTag/isX helpers for discriminated unions). It runs via MSBuild or as a standalone CLI, and is extensible with your own plugins for whatever pattern you’re tired of hand-writing. It’s Apache-2.0 licensed, actively maintained (it passed 1.0 in September 2026, making the public API stable), and has grown a small ecosystem of third-party plugins (SqlHydra, JsonWrapper, TypeSafeInternals among them).
<PackageReference Include="Myriad.Core" />
<PackageReference Include="Myriad.Sdk" />[<Generator.Fields "fields">]
type Test1 = { one: int; two: string }Source, releases, and the changelog are on GitHub. For the mechanics, see Configuration for myriad.toml and how plugins receive settings, and How It Works for the CLI/MSBuild pipeline itself.
Further reading, from when I was building it:
- Applied Meta-Programming with Myriad: the original writeup, with Falanx
- Myriad Intro: a Meta Programming Club talk introducing it
- Myriad Configuration Changes: the most recent update to the config system