Skip to main content

Type equalities for F#. These equalities allow us to create type-safe abstractions by allowing us to encode Generalised Algebraic Data Types (GADTs), as found in languages like Haskell.

Total Downloads
114.3K
114,265
Published
Oct 11, 2025
1y ago

Get Started

dotnet add package TypeEquality --version 0.4.2
ProductVersions
.NET Standard
netstandard2.0

README

TypeEquality

NuGet latest release NuGet latest pre-release Build status

Type equalities for F#

This library contains type equalities (Teqs) for F#. These equalities allow us to create type-safe abstractions by allowing us to encode Generalised Algebraic Data Types (GADTs), as found in languages like Haskell.

Ralf Hinze explains the concepts of GADTs and phantom types in Fun with phantom types. In particular, Section 7, "A type equality type", covers the role of a type equality in the encoding of GADTs.

Usage

To use Teqs in your projects, you'll want to reference the main TypeEquality project. The project is available as a nuget package - https://www.nuget.org/packages/TypeEquality.
This project provides a type Teq<'a,'b> of proofs that 'a and 'b are the same type. By including these in the declaration of a generic discriminated union, you can constrain the types each case applies to, encoding a GADT. An example of this may be found in the Example folder.

For more advanced usage, TypeEquality also allows you to reason about Teqs using the functions in the Teq and Teq.Cong (congruence) modules.

The library has some unit tests in the Test/TypeEquality.Test.fsproj project.

Contributing

We welcome new contributors! We'll happily receive PRs for bug fixes or small changes. If you're contemplating something larger please get in touch first by opening a GitHub Issue describing the problem and how you propose to solve it.

License

Copyright 2018 G-Research

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.