RaggieSoft Labs • Linear-Type Financial Compiler Research (v0.1.0-lab)
Fin# (Financial Sharp) — Enforcing Conservation of Capital at Compile Time.
“Because rules made by monopolies can be questioned. The laws of conservation cannot.”
Originating in RaggieSoft's Ocean View Archives novel series (/books/aubrie, Chapter
Question The Rules: The Birth of Fin#) and now under active engineering design in RaggieSoft Labs,
Fin# (FinSharp / finsc) brings linear resource types
to the .NET & Roslyn compiler ecosystem—turning unbalanced double-entry accounting entries, binary
floating-point rounding drift, and synthetic revenue creation from post-facto audit findings into hard compile-time
errors.
Standard Imperative Languages (C#, Java, C++, COBOL)
Money Treated as an Unconstrained Scalar
In general-purpose languages, decimal is just a mutable number. A developer or rogue script can write
companyRevenue += 500_000_000.00m; and the compiler succeeds with 0 errors and 0 warnings—even
though half a billion dollars appeared out of nowhere with zero corresponding debit, and fractional allocation
remainders can be silently dropped into garbage collection. Sarbanes-Oxley (SOX Sections 302 & 404)
only catches the corruption months later during human audits.
Fin# Linear Resource Type System (finsc)
First Law of Thermodynamics Applied to Luca Pacioli (1494)
Just as quantum programming languages forbid cloning or deleting an entangled qubit, Fin# models
Capital<TCurrency> as a protected linear resource type. Capital cannot be
instantiated out of thin air, overwritten, or dropped at scope exit; it can only move inside a balanced
transaction block where the compiler symbolically proves Σ Debits == Σ Credits
before emitting a single instruction of .NET IL!
Test How finsc Rejects Unbalanced Capital & Verifies Double-Entry Ledgers
// File: QuarterlyClose.fin — Attempting unconstrained scalar addition on an Account
ledger CorporateBooks<USD> {
account OperatingCash : Asset<USD>;
account WholesaleRevenue : Revenue<USD>;
}
fn BookSyntheticGain(books: ref CorporateBooks<USD>) {
// Illegal in Fin#: where did 500,000,000.00 USD come from? Which account was debited?
books.WholesaleRevenue += 500_000_000.00_USD;
}
Build FAILED (Exit Code 1) — Halted Before IL Emission:
QuarterlyClose.fin(9,3): error FIN0001: ConservationOfCapitalViolationException —
Account 'WholesaleRevenue' (Revenue<USD>) cannot be mutated via scalar '+=' outside an atomic
'transaction' block with a proving Debit counterparty of equal Capital<USD> magnitude.
// File: DividendSplit.fin — Splitting $100.00 USD equally across 3 accounts ($33.33 * 3 = $99.99)
transaction AllocateGrant(pool: move Capital<USD>) {
// Exact 3-way floor division returns a linear tuple: (quotient[3], remainder: 0.01_USD)
let (shares, unallocatedCents) = capital.splitEqual(move pool, parts: 3);
debit DeptResearch <- move shares[0];
debit DeptTransit <- move shares[1];
debit DeptAquatic <- move shares[2];
// Oops! 'unallocatedCents' (0.01_USD) goes out of scope without being posted!
}
Build FAILED (Exit Code 1) — Linear Resource Leak Detected:
DividendSplit.fin(10,1): error FIN0005: UnconsumedLinearCapitalError —
Linear binding 'unallocatedCents' of type 'Capital<USD>' goes out of scope unconsumed!
Route the exact remainder explicitly (e.g., 'debit RoundingReserve <- move unallocatedCents;').
Rather than carrying a 4-million-line upstream dotnet/roslyn merge burden, our primary architecture pairs
a crisp, 100-level-commented C# immutable syntax/binding/linear-flow frontend (FinSharp.Compiler) with
in-process Microsoft.CodeAnalysis.CSharp lowering & PE emission—delivering sub-second builds, full
NuGet interoperability, NativeAOT support, and PDB debugging!
Candidate Studio Tool: RaggieSoft Fin# / Ledger Studio
Pairing Accessibility Studio's proven .NET 11 + Monaco workstation shell with a live
Fin# Language Server (LSP), real-time T-account conservation diagrams, Z-SOX-302
audit proofs, and Document Studio Tagged PDF/UA-1 statement generation—following our
permanent Community == 100% Architect rule.