Conversation
Refactored the main `str` module to re-export all public functions from internal modules, providing a unified and comprehensive API surface. Added extensive documentation, grouped functions by category, and exposed advanced features, configuration, and internal types. Deprecated annotations were removed from internal/core.gleam as those functions are now only used internally. File and directory structure was updated to move implementation modules under `str/internal/`.
Introduces src/str/advanced.gleam with low-level string search algorithms and helpers, including KMP and sliding-window implementations for power users. Also adds simple variants of index_of and count to src/str.gleam for direct algorithm access.
Included a GitHub Actions CI badge in the README to display the current status of the continuous integration workflow.
Introduces tests for smart search defaults and strategy selection in the string module, including cases for minimum pattern length and small patterns.
Prevents benchmark results from being tracked by git by adding 'benchmark/results/' to the .gitignore file.
Documents the major 2.0.0 release, highlighting the migration to a single-module architecture, breaking changes, new advanced APIs, type re-exports, and improved documentation. Notes deprecations and internal restructuring.
Update the project version from 1.2.3 to 2.0.0 to reflect new changes or a major release.
Improved code formatting in src/str/advanced.gleam for readability, updated import style, and adjusted type definitions. Cleaned up imports in test/str_config_test.gleam and reformatted assertions in test/str_core_test.gleam for consistency.
There was a problem hiding this comment.
Pull request overview
This PR is a major 2.0.0 release that consolidates the library behind a single str entrypoint, introduces an str/advanced module for low-level search control, and moves implementation details into str/internal/* while cleaning up deprecations and improving documentation.
Changes:
- Unified the public API under
import str, re-exporting all previousstr/core,str/extra, andstr/tokenizefunctionality (includingSearchStrategyandFillPosition) and updating all tests to call through the unified module. - Introduced new internal modules for transliteration and decomposition (
str/internal/translit,str/internal/decompose, updatedstr/internal/extraandstr/internal/tokenize) and a newstr/advancedmodule exposing low-level KMP/sliding search primitives and caching helpers. - Bumped the library to v2.0.0, documented the breaking changes and new API in
CHANGELOG.md, added a CI badge, and slightly updated configuration and ignore patterns.
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
gleam.toml |
Bumps package version to 2.0.0, reflecting the major breaking release. |
CHANGELOG.md |
Documents the 2.0.0 unified API, breaking changes, new str/advanced module, and configuration notes. |
README.md |
Adds a CI badge and keeps general docs aligned with the new single-module API (note: badge currently points to a CI workflow while the only defined workflow is named test). |
.gitignore |
Ignores benchmark/results/, isolating benchmark artifacts from version control. |
src/str.gleam |
Replaces the old re-export shim with a full, documented public surface: defines public FillPosition and SearchStrategy types, wraps nearly all core/extra/tokenize functions, exposes advanced KMP/sliding helpers, tokenizers, and configuration getters under a single str module. |
src/str/advanced.gleam |
New public module exposing low-level KMP and sliding-window search APIs and KMP map caching; choose_search_strategy/2 currently returns the internal str/internal/core.SearchStrategy type rather than the public str.SearchStrategy. |
src/str/config.gleam |
Centralizes heuristic configuration for search (KMP thresholds and a smart_search_enabled/0 flag) and is re-exposed via str. |
src/str/internal/core.gleam |
Removes @deprecated annotations from internal functions now re-exposed via str, keeps KMP and sliding search implementations, and retains the heuristic SearchStrategy chooser used by _auto and explicit strategy APIs. |
src/str/internal/extra.gleam |
Refactors ASCII folding and slugification to use new internal decompose and translit modules, keeping behavior while clarifying pipeline docs and removing deprecations. |
src/str/internal/tokenize.gleam |
Cleans up the pure-Gleam grapheme tokenizer implementation by removing deprecation tags; now used via str.chars/1 and str.chars_stdlib/1. |
src/str/internal/translit.gleam |
New internal module containing the ASCII transliteration table and a helper to strip Unicode combining marks; lookup is used by internal extra/slug APIs. |
src/str/internal/decompose.gleam |
New internal module implementing limited Latin decomposition to base+combining-mark; includes a table of decompositions, although the entries for Œ/œ are currently incorrect. |
test/str_unicode_test.gleam |
Updates imports to use str directly for ascii_fold and truncate_preserve Unicode tests. |
test/str_tokenize_compare_test.gleam |
Switches from str/tokenize to str, using str.chars and str.chars_stdlib to compare tokenizer behavior. |
test/str_strategy_test.gleam |
Uses str.choose_search_strategy and str.Sliding/str.Kmp, verifying the strategy heuristics via the public API. |
test/str_strategy_explicit_test.gleam |
Switches most calls to str while still using str/internal/core for low-level search-all tests; checks that explicit strategy wrappers in str match the internal implementations. |
test/str_sliding_test.gleam |
Routes sliding-window search tests through str.sliding_search_all, validating the re-exported advanced search helpers. |
test/str_normalizer_integration_test.gleam |
Uses str.ascii_fold_with_normalizer and str.slugify_opts_with_normalizer, ensuring normalization hooks still behave correctly through the unified API. |
test/str_multilingual_test.gleam |
Updates to str and str/internal/decompose for multilingual ASCII folding/slug tests and direct decomposition sanity checks. |
test/str_kmp_test.gleam |
Switches KMP search and prefix-table tests to str’s KMP wrappers, covering the re-exported advanced search APIs. |
test/str_kmp_cache_test.gleam |
Uses str.build_kmp_maps and str.kmp_*_with_maps to validate reuse of KMP maps via the public API. |
test/str_integration_test.gleam |
Points all integration-style string pipelines (truncate, slugify, casing, padding, reversing) at the unified str module. |
test/str_extra_test.gleam |
Updates all extra usage to str, and imports str/internal/decompose and str/internal/translit for internal helper testing (e.g., remove_combining_marks, decompose_latin). |
test/str_extra_full_test.gleam |
Uses str and str/internal/decompose to exercise full ASCII fold, slugify, and truncation edge cases through the new API. |
test/str_corpus_test.gleam |
Routes corpus-based folding tests through str.ascii_fold. |
test/str_core_test.gleam |
Large test suite updated to call the new str-based API for grapheme operations, padding, searching, validation, escaping, and more; now covers the unified entrypoint instead of str/core and str/tokenize. |
test/str_config_test.gleam |
New tests verifying the default smart_search_enabled/0 flag and that str.choose_search_strategy/2 honors kmp_min_pattern_len/0 thresholds. |
test/str_combining_test.gleam |
Switches combining-mark ASCII folding tests to str.ascii_fold. |
test/str_auto_test.gleam |
Ensures the _auto search/count routines exposed on str match the legacy index_of/count semantics across cases. |
Notable issues identified:
- In
src/str/internal/decompose.gleam, the decomposition entries forŒ/œare incorrect ("O\u{014B}E"/"o\u{014B}e"instead of decomposing toOE/oe), which can yield wrong results for direct users ofdecompose_latin/1. - In
src/str/advanced.gleam,choose_search_strategy/2returns the internalstr/internal/core.SearchStrategytype rather than the publicstr.SearchStrategy, unintentionally exposing an internal type through the advanced API. - The new CI badge in
README.mdtargets aCIworkflow name, but the only defined workflow is namedtestin.github/workflows/ci.yml, so the badge likely won’t reflect the actual CI status until one of them is aligned.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <p align="center"> | ||
| <a href="https://hex.pm/packages/str"><img src="https://img.shields.io/hexpm/v/str" alt="Package Version"></a> | ||
| <a href="https://hexdocs.pm/str/"><img src="https://img.shields.io/badge/hex-docs-ffaff3" alt="Hex Docs"></a> | ||
| <a href="https://github.com/lupodevelop/str/actions"><img src="https://img.shields.io/github/workflow/status/lupodevelop/str/CI?label=ci&logo=github" alt="CI"></a> |
There was a problem hiding this comment.
The CI badge URL references a CI workflow (github/workflow/status/.../CI), but the only workflow defined in .github/workflows/ci.yml is named test, so this badge is unlikely to display the correct status. Consider updating the badge to target the existing test workflow (or renaming the workflow to match the badge) using the current Shields.io GitHub Actions endpoint.
| <a href="https://github.com/lupodevelop/str/actions"><img src="https://img.shields.io/github/workflow/status/lupodevelop/str/CI?label=ci&logo=github" alt="CI"></a> | |
| <a href="https://github.com/lupodevelop/str/actions"><img src="https://img.shields.io/github/actions/workflow/status/lupodevelop/str/ci.yml?branch=main&label=ci&logo=github" alt="CI"></a> |
| ) -> core.SearchStrategy { | ||
| core.choose_search_strategy(text, pattern) | ||
| } | ||
|
|
||
| /// Helper types for users building caches. |
There was a problem hiding this comment.
choose_search_strategy/2 returns the internal str/internal/core.SearchStrategy type, which leaks an internal module type through the public str/advanced API instead of using the public str.SearchStrategy re-export. This makes it harder to use from callers who want to avoid importing internal modules; consider returning the public str.SearchStrategy (and mapping internally) for a cleaner public surface.
| ) -> core.SearchStrategy { | |
| core.choose_search_strategy(text, pattern) | |
| } | |
| /// Helper types for users building caches. | |
| ) -> SearchStrategy { | |
| core.choose_search_strategy(text, pattern) | |
| } | |
| /// Helper types for users building caches. | |
| pub type SearchStrategy = | |
| core.SearchStrategy |
This pull request is a major release (v2.0.0) that completes the transition to a unified, single-module API for the
strlibrary. It consolidates all public functionality under a single entry point, introduces a newstr/advancedmodule for power users, and removes deprecated APIs. The internal structure has been reorganized for clarity, and documentation has been improved. This release contains breaking changes, so users should update their imports and review the new API surface.API Consolidation and Breaking Changes
str/core,str/extra, andstr/tokenizeare now internal; users should import fromstrinstead. Deprecated APIs have been removed, and types likeSearchStrategyandFillPositionare re-exported directly fromstr. (CHANGELOG.md,src/str/internal/core.gleam) [1] [2]–[3]str/internal/*, and the version is bumped to 2.0.0. (gleam.toml,CHANGELOG.md) [1] [2]New Advanced Module
str/advancedfor low-level control and benchmarking, exposing direct access to KMP and sliding-window algorithms, as well as helper types and strategy selection. (src/str/advanced.gleam,CHANGELOG.md) [1] [2]Documentation and Quality of Life
CHANGELOG.md)README.mdfor better project visibility. (README.md)Deprecation and Cleanup
@deprecatedannotations for soon-to-be-removed APIs have been removed from internal code, as these APIs are now internal and not intended for public use. (src/str/internal/core.gleam) [1]–[2]Please review the changelog for migration steps and details on new and changed APIs.