Proposal: add a dependency injection feature to the language #2098
Replies: 3 comments 5 replies
-
Hello! I'm keen to understand the proposal better. What would What would be the type of the |
Beta Was this translation helpful? Give feedback.
-
Totally agree, Dependency Injection is required for referential transparent programs with mocked IO and well covered with unit tests. |
Beta Was this translation helpful? Give feedback.
-
Anyway, I implemented my bicycle, inspired via Reader monad |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @lpil,
I have a nice idea of a dependency injection feature. A dependency-getter can be defined with a function:
names_of_deps
are names of the dependencies - a tuple. For example, we can have ajwt_auth
function as a getter, and the deps could be user, his permissions and the additional info. The target arg would be the http request.Normally, the getter function would be called like this:
I propose a special syntax for this:
Or, if we only need the user dependency, we shall write
And the underlying function call will be
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions