Skip to content

Repository files navigation

Pure.Primitives

Concrete implementations of immutable, composable primitive types for the Pure ecosystem — type-safe wrappers over .NET primitive types with full AOT compatibility.

.NET build & testNuGet publishNuGetLicense: MIT

Overview

Pure.Primitives provides sealed record implementations of every interface defined in Pure.Primitives.Abstractions. Each type wraps a single .NET primitive value with lazy evaluation, is immutable by design, and exposes no mutation surface. All types implement GetHashCode and ToString as throw new NotSupportedException() — equality and formatting flow through the underlying value, not the wrapper.

Types

Bool

TypeImplementsDescription
TrueIBoolSingleton representing true
FalseIBoolSingleton representing false

Char

TypeImplementsDescription
CharICharSingle Unicode character

Number (INumber<T>)

TypeUnderlying type
Intint
Longlong
Shortshort
UIntuint
ULongulong
UShortushort
Doubledouble
Floatfloat
Decimaldecimal
Zerogeneric 0
MinInt / MaxIntint.MinValue / int.MaxValue
MinLong / MaxLonglong.MinValue / long.MaxValue
MinShort / MaxShortshort.MinValue / short.MaxValue
MinDouble / MaxDoubledouble.MinValue / double.MaxValue
MinFloat / MaxFloatfloat.MinValue / float.MaxValue
MinDecimal / MaxDecimaldecimal.MinValue / decimal.MaxValue
MinUint / MaxUintuint.MinValue / uint.MaxValue
MinUlong / MaxUlongulong.MinValue / ulong.MaxValue
MinUshort / MaxUshortushort.MinValue / ushort.MaxValue

Date / Time

TypeImplementsDescription
DateIDateComposed of INumber<ushort> day, month, year
TimeITimeHour, minute, second, millisecond, microsecond, nanosecond
DateTimeIDateTimeComposite of IDate and ITime
CurrentDateIDateToday's date
CurrentTimeITimeCurrent time
CurrentDateTimeIDateTimeCurrent date and time
DateValidStateIBoolWhether a Date value is in range
TimeValidStateIBoolWhether a Time value is in range
HoursValidStateIBoolWhether hours are 0–23
MinutesValidStateIBoolWhether minutes are 0–59
SecondsValidStateIBoolWhether seconds are 0–59
MillisecondsValidStateIBoolWhether milliseconds are 0–999
MicrosecondsValidStateIBoolWhether microseconds are 0–999
NanosecondsValidStateIBoolWhether nanoseconds are 0–999

Day of Week

Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday — each implements IDayOfWeek with DayNumberValue 1–7.

Guid

TypeImplementsDescription
GuidIGuidWraps a System.Guid
EmptyGuidIGuidGuid.Empty
UlidIGuidULID generated via ByteAether.Ulid, stored as System.Guid

String

TypeImplementsDescription
StringIStringLazy string built from any IBool, IChar, INumber<T>, IDate, ITime, IDateTime, IDayOfWeek, IGuid, or raw string
EmptyStringIString""
NewLineStringIStringEnvironment.NewLine
WhitespaceStringIString" "
ColonStringIString":"
CommaStringIString","
DotStringIString"."
SemicolonStringIString";"
SingleQuoteStringIString"'"
DoubleQuoteStringIString"\""
LeftRoundBracketStringIString"("
RightRoundBracketStringIString")"
LeftSquareBracketStringIString"["
RightSquareBracketStringIString"]"
LeftCurlyBracketStringIString"{"
RightCurlyBracketStringIString"}"

Design Principles

  • Immutable — no setters, no mutation; state is captured at construction time.
  • Lazy — internal values are wrapped in Lazy<T>; evaluation is deferred until first access.
  • Composable — types accept other Pure interfaces as constructor arguments, enabling composition without unwrapping.
  • AOT-compatibleIsAotCompatible = true; no reflection, no dynamic code generation.

Dependencies

  • Pure.Primitives.Abstractions — base interfaces (IBool, IChar, INumber<T>, IDate, ITime, IDateTime, IDayOfWeek, IGuid, IString) that every type in this package implements

Target Frameworks

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

Installation

dotnet add package Pure.Primitives

Usage

usingPure.Primitives.Number;usingPure.Primitives.Date;usingPure.Primitives.String;// Compose primitives from other primitives — no raw .NET types needed at call sitesINumber<int>count=newInt(42);IDatetoday=newCurrentDate();IStringlabel=newString(today);// "5/22/2026" — lazy, evaluated on first access// Boundary constantsINumber<int>max=newMaxInt();// int.MaxValue

About

Concrete implementations of immutable, composable primitive types for the Pure ecosystem — type-safe wrappers over .NET primitive types; AOT-compatible.

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages