Skip to content

Releases: Spellbound-Mojo/fp_mojo

FP Mojo 1.0.1

Choose a tag to compare

@anatolvitold anatolvitold released this 20 Oct 16:30

FP Mojo 1.0.1 adds method chaining to fp.iteration for writing lazy transformations from left to right.

  • Start a chain with iterated(source). Chain map, filter, filter_map, flat_map, flatten and scan_left, then finish with a fold, reduction, search or collection.
  • Collect explicitly into a list. .to_list() and .collect_list() are aliases for the same consuming operation. Existing free functions remain available.
  • Use standard-library adapters directly. The new Iter wrapper implements native Iterator and IterableOwned, so operations such as enumerate(iterated(values^)) work under their native type and ownership requirements. Wrap a standard adapter with iterated(...) to resume method chaining.
  • Keep native ownership and error semantics. Chains preserve iterator position, borrowed origins, move-only values and captured callback state. Raising terminals preserve their declared error types; lazy callbacks remain non-raising. The wrapper delegates to the existing iteration implementations and adds no buffering or allocation.
  • Expanded documentation. Updated the iteration tutorial, architecture guide and executable examples; added algebra and Reader, State and Writer tutorials; revised the README and documentation site.

Validation includes 200 passing suite tests, 294 expected compile-time rejections, 128 documentation example runs and 28 tooling tests. Source and precompiled package builds and strict documentation checks passed.

See the iteration tutorial and full changelog.

FP Mojo 1.0.0

Choose a tag to compare

@anatolvitold anatolvitold released this 02 Oct 15:24

The first release of FP Mojo: functional programming for Mojo 1.1.

  • Pipelines and composition: pipe, piped, flow, compose, flip and partial, with every intermediate type inferred and errors kept with their own types.
  • Lazy iteration and folds over native iterators and owned collections: map, filter, filter_map, flat_map, scan_left, fold_left, fold_until, reduce, find, any, all.
  • Results: Result with map, flat_map, map_err, or_else and folds, plus attempt, raise_on_err and collect_results between raised and stored errors.
  • Algebraic data types and pattern matching: declare a type from ordinary structs and match it with fp.match, checked for exhaustiveness when the program compiles. Recursive values are evaluated in a loop, with no recursion depth limit. Choice stores a non-recursive value in place, and Result, ControlFlow and Optional are matched the same way.
  • Loops as expressions: while_loop, fori_loop and carry/output scan.
  • Functor, Applicative, Monad, Traversable and Monoid, with Identity, Optional, Result and List instances, and Reader, State, Writer, OptionalT and ResultT transformers.

Works with Mojo 1.1.x on Linux x86-64 and macOS arm64.

Install from the Modular community channel (available once modular/modular-community#387 is merged):

# pixi.toml
[workspace]
channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
pixi add fp_mojo

Documentation: https://spellbound-mojo.github.io/fp_mojo/