Thanks for the reply.
Yes, that snippet is an example of using the derive_tinantas method, and likewise there are currently derive_subantas, derive_krdantas, derive_taddhitantas, and derive_vakyas methods. I am also considering a derive_samasas method, a derive_dhatus method, and a derive_stryantas method for स्त्री-pratyayas.
Audience: I expect that the users of this API will be power users who are familiar with Paninian grammar. I likewise foresee most people who use this package using it through the Python API, which for ease of maintenance will broadly mirror the Rust one but with some tweaks to be more Pythonic.
Goal for this project: The primary goal is to generate an exhaustive Sanskrit word list by following the rules of the Ashtadhyayi, etc. An important second goal is to have a complete reference implementation of the Ashtadhyayi, (I use the phrase "reference implementation" and avoid the word "simulation" because a simulation implies some explicit model of how to resolve conflicts between rules, which this project does not have.)
Goal for the API: My goal is to make the API as complex as it needs to be for the problem domain (i.e. the Ashtadhyayi) but avoid complexity from the language, clumsy API design, etc.
Motivating example: I'll focus on derive_tinantas. Here are properties I like:
- Has clear constraints based on Rust's enum types
- Easy to create a new Ashtadhyayi instance, which can model which rules apply, how to interpret certain rules, etc.
- Easy to create a dhatu. SLP1 is not ideal, but supporting other encodings would require transliterator support, which feels out of scope for this library.
Here are properties I don't like:
- Not obvious how to create a नामधातु. More generally, some methods could conceivably accept a bare pratipadika, a krdanta, a taddhitanta, a subanta, or perhaps even a verb. Rust's
impl trait arguments might be able to support this, but it needs some more thought.
- Not obvious where to specify upasargas and other prefixes. Right now these are defined on Dhatu, but is that a natural place? Perhaps these should be a third argument -- but then that's clumsy if the user doesn't want to specify any prefixes. So perhaps prefixes should be on TinantaArgs -- but if so, perhaps dhatu should also be defined as part of TinantaArgs?
One idea I like, that I think you mentioned in a past conversation, is to allow TinantaArgs to have unspecified fields as a "generate everything" option. That is, if a user doesn't pass an explicit lakara, we should generate all lakaras that fit the constraints given. I think this is a great way to make the API more user friendly without sacrificing its precision.
Arun