Iāve run into situations where it makes sense to parameterize modules on types, constants, statics, or maybe other items. Iāve used a Haskell feature implicit parameters for functions, but they always felt tricky to mentally parse.
I wonder if providing only module level implicit parameters might make more sense? In particular, if I want an implicit parameter then itās almost always because itās a module wide, or even crate wide, configuration parameter, but I do not want to choose between making something a parameter everywhere vs using features and/or vendoring dependencies.
Iād rather side step any discussion of syntax by using a new keyword implicit which probably does not really work.
mod ParamaterizedModule {
implicit type TypeParam : ParamaterTrait;
implicit const ConstantParam : Type;
...
}
You can only reference or use items from ParamaterizedModule when both a TypeParam satisfying ParamaterTrait and a ConstantParam of type Type are in scope.
Rust would treat these as parameters for any items dependent upon them under the hood, but you could not specify them directly. A priori, an implicit const benefits from a degree of dependent types, but simpler schemes might work, perhaps only supporting static.
Is there reason to think that doing implicit parameters at the module level might make them more useful and comprehensible?