Skip to content

kudima03/Pure.Primitives.Abstractions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

175 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pure.Primitives.Abstractions

Base interfaces for the Pure ecosystem — immutable, composable abstractions over .NET primitive types.

.NET build & test Platforms compatibility check Build and Deploy NuGet License: MIT

Overview

Pure.Primitives.Abstractions defines a set of minimal, read-only interfaces that represent primitive values. Each interface exposes only a getter — no mutation, no side effects. Complex types are built by composing simpler ones.

Interfaces

Interface Namespace Description
IBool Pure.Primitives.Abstractions.Bool Boolean value
IChar Pure.Primitives.Abstractions.Char Single character
IString Pure.Primitives.Abstractions.String String value; implements IEnumerable<IChar>
INumber<T> Pure.Primitives.Abstractions.Number Generic numeric value; T : INumber<T>
IDate Pure.Primitives.Abstractions.Date Date (day, month, year via INumber<ushort>)
ITime Pure.Primitives.Abstractions.Time Time (hour, minute, second, millisecond, microsecond, nanosecond)
IDateTime Pure.Primitives.Abstractions.DateTime Composition of IDate and ITime
IDayOfWeek Pure.Primitives.Abstractions.DayOfWeek Day of week as a numeric value
IGuid Pure.Primitives.Abstractions.Guid GUID value

Design Principles

  • Immutable — all interfaces expose only get properties; no setters, no methods that mutate state.
  • Composable — complex types inherit from simpler ones (IDateTime : IDate, ITime; IString : IEnumerable<IChar>).
  • GenericINumber<T> is covariant (out T) and constrained to System.Numerics.INumber<T>, supporting any numeric type.
  • AOT-compatible — the library is fully compatible with Native AOT compilation.

Target Frameworks

  • .NET 7
  • .NET 8
  • .NET 9
  • .NET 10

Installation

dotnet add package Pure.Primitives.Abstractions

Usage

Implement any interface to model an immutable primitive in your domain:

using Pure.Primitives.Abstractions.Number;

public sealed class Age : INumber<ushort>
{
    public Age(ushort value) => NumberValue = value;
    public ushort NumberValue { get; }
}

Compose interfaces to build richer types:

using Pure.Primitives.Abstractions.DateTime;

public sealed class BirthDateTime : IDateTime
{
    // implement IDate and ITime members
}

About

Base interfaces for the Pure ecosystem

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages