Skip to content

fix!: correct public typing contracts - #67

Merged
dbrattli merged 4 commits into
masterfrom
fix/public-typing-contracts
Oct 28, 2026
Merged

dbrattli merged 4 commits into
masterfrom
fix/public-typing-contracts

Conversation

@dbrattli

Copy link
Copy Markdown
Owner

Summary

Make the exported typing contracts usable from caller code and include the PEP 561 marker in the wheel. Monad and Applicative now name their concrete result containers, so structural assignments can be checked without widening the concrete APIs to Any. Add caller-side Pyright checks for the supported families.

Correct the wrapped-function apply signatures and add overloads for unary and two-argument functions. Two-argument application still curries; a TypeError raised inside a unary function now propagates instead of being mistaken for a currying request.

Writer.map now transforms its value while preserving the log. Writer.map_with_log retains the old tuple-transforming operation. Writer.unit exposes its string-log default in its return type and accepts empty_log for other log types.

Typing and API changes

  • Monad[T] becomes Monad[T, Result], where Result is the concrete container returned by bind.
  • Applicative[T] becomes Applicative[WrappedFunction, ArgumentContainer, ResultContainer].
  • Functor[T] describes same-type map operations; concrete classes still type their value-changing map methods.
  • Callers whose Writer.map callback transforms (value, log) should use Writer.map_with_log.
  • Writer.unit(value) is typed as returning a string-log writer. Pass empty_log for another log type, or use a writer class created with Writer.create.

@dbrattli dbrattli changed the title Fix public typing contracts fix: Fix public typing contracts Oct 28, 2026
@dbrattli dbrattli changed the title fix: Fix public typing contracts fix!: correct public typing contracts Oct 28, 2026
@dbrattli
dbrattli merged commit bae0e4d into master Oct 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant