A practical F# library for datatype-generic programming using reflection and visitor patterns to minimize boilerplate.
TypeShape is an F# library for practical datatype-generic programming. It uses reflection and visitor patterns to derive the algebraic structure of types, enabling developers to write generic programs that work across records, unions, POCOs, and other type shapes with minimal boilerplate and improved performance.
F# developers building serialization libraries, configuration parsers, equality comparers, or other applications requiring generic type manipulation without excessive reflection overhead.
Developers choose TypeShape for its performance optimizations over raw reflection, extensible architecture for custom type shapes, and support for both traditional and higher-kinded type APIs, making it a versatile tool for generic programming in F#.
Practical generic programming for F#
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show significant improvements over raw reflection, as detailed in the performance page, reducing overhead for generic programs.
Supports custom active patterns for arbitrary shapes, like ISerializable, allowing developers to add new type algebras without modifying core library.
Provides built-in active patterns for F# records, unions, and POCOs, simplifying generic programming for common F# datatypes.
Enables type-safe generic programs with a modern approach, as shown in the HKT examples, reducing boilerplate for advanced use cases.
Primarily designed for F#, making it unsuitable for mixed-language or C#-focused projects, as highlighted by its dependency on F# idioms.
Requires deep understanding of generic programming concepts and F# patterns, which can be daunting for developers new to datatype-generic programming.
Despite optimizations, it still relies on System.Reflection internally, which may introduce overhead or compatibility issues in reflection-restricted environments.