Skip to content

Release/fp library v0.12.0#19

Merged
nothingnesses merged 12 commits intomainfrom
release/fp-library-v0.12.0
Mar 13, 2026
Merged

Release/fp library v0.12.0#19
nothingnesses merged 12 commits intomainfrom
release/fp-library-v0.12.0

Conversation

@nothingnesses
Copy link
Copy Markdown
Owner

No description provided.

…'s `Bind`

Adds `bind_flipped`, `join`, `compose_kleisli`, and `compose_kleisli_flipped`
as free functions on `Semimonad`, and `if_m` on `Monad` (which requires `pure`
via `Applicative`). if_m uses a `Clone` bound on branches to support
multi-element monads like `Vec`.
Implement a proc macro that desugars Haskell/PureScript-style do-notation
into nested `bind` calls, eliminating rightward drift in monadic code.

Supported statement forms:
- `x <- expr;` — monadic bind
- `x: Type <- expr;` — bind with type annotation
- `_ <- expr;` / `expr;` — sequence (discard result)
- `let x = expr;` / `let x: Type = expr;` — pure let binding
- `pure(expr)` — auto-rewritten to `pure::<Brand, _>(expr)`

Also reorganize feature lists in lib.rs and README.md for clarity, and
add consistent `// Invocation` / `// Expanded code` examples to all
`document_*` macro doc comments.
- Add Alt, Plus, and Alternative type class definitions in classes/
- Implement Alt and Plus for Option, Vec, and CatList
  (Alternative follows via blanket impl for Applicative + Plus)
- Re-export plus_empty in functions.rs

- Add ### Laws sections with law-checking doc examples to:
  Compactable (identity + conditional laws with Plus),
  Filterable (distributivity, identity, composition, consistency),
  Witherable (identity, multipass filter/partition)

- Add law-checking doc examples to traits that had law statements
  but no code examples: Applicative, Bifunctor, Category,
  Contravariant, Monoid, Semigroup, Semigroupoid, Semiapplicative

- Expand Monad module docs with m! macro examples (Option, Vec,
  Result) and add monad law examples (left/right identity,
  associativity) for Option and Vec

- Add Vec law examples to Functor

- Fix Profunctor composition law: g argument order was reversed

- Update docs/todo.md
Add PureScript-style type class hierarchy for numeric types:
Semiring, Ring, CommutativeRing, EuclideanRing, DivisionRing, Field,
and HeytingAlgebra, with instances for all Rust numeric primitives
and bool. Integer instances use wrapping arithmetic for consistent
debug/release behavior.

Add 7 newtype wrappers with Semigroup/Monoid instances:
Additive, Multiplicative, Conjunctive, Disjunctive, First, Last,
and Dual.

Move integration tests from tests/property_tests/ into inline #[cfg(test)]
modules and extend document_examples proc macro to handle #[doc = concat!()] attributes.
Add trait-level `#[document_examples]` with law assertions to seven
traits, following PureScript's purescript-foldable-traversable as the
reference for which laws to document:

- Foldable: fold_map/fold_right internal consistency
- Traversable: traverse/sequence consistency (both directions)
- FunctorWithIndex: identity and Functor compatibility
- FoldableWithIndex: Foldable compatibility
- TraversableWithIndex: Traversable compatibility
- Bifoldable: bi_fold_map/bi_fold_right consistency
- Bitraversable: bi_traverse/bi_sequence consistency via bimap
Rename `greatest_common_divisor` → `gcd` and `least_common_multiple` →
`lcm` in euclidean_ring for brevity.

Add missing derived combinators ported from PureScript's prelude:
- `power` (monoid): binary exponentiation via repeated `append`
- `when`/`unless` (applicative): conditional actions on plain `bool`
- `when_m`/`unless_m` (monad): conditional actions on monadic `bool`
- `on` (functions): apply binary function after projecting both args
- `lift3`/`lift4`/`lift5` (lift): higher-arity lifting via nested `lift2`

Fix 15 broken rustdoc links in newtype wrapper module docs by
qualifying trait references with full `crate::classes::` paths.
Implement PureScript-style applicative do-notation that desugars into
`pure`/`map`/`lift2`–`lift5` depending on the number of bindings.
Unlike `m!`, bindings are independent — later bind expressions cannot
reference earlier bound variables.

- 0 binds → `pure`, 1 → `map`, 2–5 → `liftN`
- `let` bindings before any `<-` are hoisted outside the combinator
- `let` bindings after a `<-` go inside the combining closure
- `pure(...)` in bind expressions is auto-rewritten with the brand
- Reuse `DoInput` parser and `rewrite_pure` from `m!` implementation
- Update applicative module docs to showcase `ado!`
- Reorder CLAUDE.md verification steps to fmt → clippy → doc → test
Equal-length snake_case names encourage `a_do!` (applicative, preferred)
over `m_do!` (monadic) and align with the library's naming conventions.

Renames modules `do_notation` → `m_do`, `ado_notation` → `a_do`, and
updates all doc comments, tests, and examples across the workspace.
…creation

Move change review and version bump steps before branch creation so
the version number is known when naming the branch. Split changelog
work into recording changes under [Unreleased] during review and
finalizing the section header after versioning.
@nothingnesses nothingnesses merged commit 05bcbac into main Mar 13, 2026
9 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