revelrylabs / text_chunker_ex

A library for semantically coherent text chunking
MIT License
66 stars 4 forks source link

API Design - the `:strategy` option should take a module instead of a function #11

Closed grossvogel closed 6 months ago

grossvogel commented 6 months ago

Background

We have a behavior for chunking strategies, which is a great way to document a pluggable interface, but we're not using it to its fullest because the :strategy option takes a function capture instead of a module that implements the behavior.

If we ever needed to add another function to the behavior, we'd also have to change the way the caller specifies the strategy. If we use the behavior instead and modify it to add the new function, the change would just work as long as the client code's strategy fits the updated behavior definition, and the compiler would complain otherwise.