Fidelity.Toml 0.1.1

dotnet add package Fidelity.Toml --version 0.1.1
                    
NuGet\Install-Package Fidelity.Toml -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fidelity.Toml" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fidelity.Toml" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Fidelity.Toml" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fidelity.Toml --version 0.1.1
                    
#r "nuget: Fidelity.Toml, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fidelity.Toml@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fidelity.Toml&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Fidelity.Toml&version=0.1.1
                    
Install as a Cake Tool

Fidelity.Toml

License: MIT TOML

A fully TOML 1.0.0 compliant parser for F#, built with XParsec.

Overview

Fidelity.Toml is a pure F# implementation of a TOML 1.0.0 parser using parser combinators. It is designed to be:

  • Spec-compliant: Full TOML 1.0.0 support including all data types, datetime formats, and structural features
  • Pure F#: No external parsing dependencies beyond XParsec
  • Self-hosting ready: Part of the Fidelity Framework toolchain infrastructure

Part of the Fidelity Framework

This library is a component of the Fidelity Framework - an ecosystem for compiling F# to native code without the .NET runtime.

Why a Separate TOML Library?

Fidelity.Toml exists as a standalone library because:

  1. Self-hosting path: As the Fidelity toolchain matures toward self-hosting, every dependency must be expressible in native F#. Having a pure F# TOML parser (using XParsec) ensures the entire toolchain can eventually compile itself.

  2. Shared infrastructure: Both the Firefly compiler and FsNativeAutoComplete (the LSP server) need to parse .fidproj project files. A shared library eliminates duplication.

  3. General utility: A compliant TOML parser is useful beyond project files - configuration, data exchange, and more.

  4. Joy: XParsec is a great library and I really dig working with it.

Installation

dotnet add package Fidelity.Toml

Or add to your .fsproj:

<PackageReference Include="Fidelity.Toml" Version="0.1.0" />

Usage

open Fidelity.Toml

// Parse a TOML string
let toml = """
[package]
name = "my-project"
version = "1.0.0"

[build]
sources = ["Main.fs", "Lib.fs"]
output = "myapp"
"""

match Toml.parse toml with
| Ok document ->
    // Access values
    let name = Toml.getString "package.name" document  // Some "my-project"
    let sources = Toml.getStringArray "build.sources" document  // Some ["Main.fs"; "Lib.fs"]
    printfn "Project: %A" name

| Error msg ->
    eprintfn "Parse error: %s" msg

Supported TOML Features

Data Types

Type Example Status
String (basic) "hello\nworld" Supported
String (literal) 'C:\path\to\file' Supported
String (multiline) """...""" Supported
Integer (decimal) 42, 1_000_000 Supported
Integer (hex) 0xDEADBEEF Supported
Integer (octal) 0o755 Supported
Integer (binary) 0b11010110 Supported
Float 3.14, 5e10, inf, nan Supported
Boolean true, false Supported
Offset Date-Time 1979-05-27T07:32:00Z Supported
Local Date-Time 1979-05-27T07:32:00 Supported
Local Date 1979-05-27 Supported
Local Time 07:32:00 Supported

Structural Features

Feature Example Status
Tables [section] Supported
Nested Tables [section.subsection] Supported
Inline Tables point = { x = 1, y = 2 } Supported
Arrays ports = [80, 443] Supported
Array of Tables [[products]] Supported
Dotted Keys physical.color = "red" Supported
Comments # comment Supported

API Reference

Parsing

/// Parse a TOML string into a document
val parse : string -> Result<TomlDocument, string>

Value Access

/// Get a string value by dotted key path
val getString : string -> TomlDocument -> string option

/// Get an integer value
val getInt : string -> TomlDocument -> int64 option

/// Get a float value
val getFloat : string -> TomlDocument -> float option

/// Get a boolean value
val getBool : string -> TomlDocument -> bool option

/// Get an array of strings
val getStringArray : string -> TomlDocument -> string list option

/// Get a table (sub-document)
val getTable : string -> TomlDocument -> TomlDocument option

Building from Source

git clone https://github.com/FidelityFramework/Fidelity.Toml.git
cd Fidelity.Toml
dotnet build
dotnet test

Contributing

Contributions are welcome! Please see the Fidelity Framework contributing guidelines.

License

MIT License - see LICENSE for details.


Part of the Fidelity Framework - Native F# for everyone.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 112 2/9/2026