zero_nads 0.0.1
zero_nads: ^0.0.1 copied to clipboard
A zero runtime cost framework for structuring code within monad-style wrappers.
0.0.1 #
Core monadic types #
Option<T>— zero-cost extension type wrappingT?;Some(value)/Noneconstructors;map,flatMap,filter,getOrElse,getOrThrow,fold,toResult,toEither, and more.Either<L, R>— discriminated union of a left and right value;Left/Rightconstructors;map,mapLeft,flatMap,fold,swap,toOption,toResult, and more.Result<T>— success-or-failure with an optionalStackTrace;Success/Failureconstructors;map,flatMap,recover,fold,getOrThrow,toOption,toEither, and more.Task<T>— lazy, deferredFuture-based computation;run,map,flatMap,zip,catchError, and more.Flow<T>— lazy, deferredStream-based computation;run,map,flatMap,filter,fold, and more.
Additional types #
Snapshot<T>— eager hot-stream wrapper with consecutive-distinct deduplication; exposes a writablevaluesetter that pushes to the stream; optional source stream for seeding initial values.
Extension methods #
FutureExtension—task(),toResult()onFuture<T>.StreamExtension—toFlow()onStream<T>.IterableExtension—flow(),firstOption,lastOption, monadic sequence helpers onIterable<T>.
Precondition helpers #
check,require,checkNotNull,requireNotNull— throwStateError(internal invariant) orArgumentError(bad caller input) with optional lazy message builders.
Annotations #
@throws— marks any function whose body may raise; imported fromlib/src/internal/throws.dart.@eager/@lazy— required on every extension type declaration; signal whether the backing value is a concrete result or a deferred computation.@inline/@noinline—vm:prefer-inline/vm:never-inlinepragmas for standalone hot-path and error-path functions.
Internals #
typedefs.dart— single source of truth for all function-type aliases (Calculation<T>,Callable,MessageBuilder,Predicate<T>,Reducer<A,T>,Transformation<T,R>,ValueCallable<T>).EitherData/ResultDatarecord types kept@internal.