tiny_types 1.0.0
tiny_types: ^1.0.0 copied to clipboard
Small, focused types for Dart with explicit invariants and practical APIs. Includes Option, Unit, and non-empty collections.
1.0.0 Oct 16, 2026 #
Initial stable release. Requires Dart ^3.0.0.
-
Option: add sealed
Option<T>withSome<T>andNone, supporting pattern matching, value equality, transformations, composition, lazy fallbacks, and side effects.Some(null)remains present;Option.fromNullableandtoOption()treatnullas absence. -
Collection lookups: add presence-preserving
OrNonelookups for iterables and maps. Selectednullvalues remain present. Single-element lookups returnNonefor zero or multiple elements or matches; map lookups respect the map's own key equality rules. -
Unit: add
Unit.valuefor a meaningful result with no payload, plus a sharedUnit.futurethat completes with that value. -
Non-empty collections: add immutable
NonEmptyList<T>,NonEmptySet<T>, andNonEmptyMap<K, V>, with a sealedNonEmptyIterable<T>base for lists and sets. Each collection guarantees at least one element or entry. Lists preserve order and duplicates, sets keep first-occurrence order, and maps keep key insertion order. Provide structural equality, unmodifiable views, and modifiable copies. -
Collection operations: add non-mutating additions, non-empty-preserving transformations, deduplication, zip/unzip, flattening, and checked casts. Standard iterable transformations stay lazy; non-empty-preserving transformations are eager. Conversions from possibly empty inputs offer
OrNull,OrNone, andOrThrowvariants, withStateErrorfor empty input in throwing conversions.