Guiding principles of effect design #1395
Replies: 2 comments 5 replies
-
|
This is great! It seems these principles work well for both introducing effects in Kyo's codebase itself and user codebases. We might need an even more constrained version with more warnings to discourage uncontrolled proliferation of new effects, especially user-defined ones.
Can you elaborate on this with an example? It's not clear to me.
Other good example is if a new effect significantly reduces the number of tracked effects and hides implementation details. An example is
Can you also elaborate on this?
Another important category is effects that manipulate the control flow via continurations like What do you think about also documenting the pattern of composite effects via |
Beta Was this translation helpful? Give feedback.
-
|
Quick stab at turning some of these thoughts into a "do/don't" list:
|
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.
-
I wanted to propose some principles to guide decisions about whether a custom effect should be provided for a given use case. Would love to hear feedback and suggested changes/additions.
provideto satisfy anEnveffect in each method. This means you are essentially just using the service pattern but in a more complicated and verbose way.Envto be used only in service constructors, which can be abstracted asLayers.LogandConsoleare the only ones I can think of that really fit this description.ChoiceandVarare utilities which will generally be useful for an implementation but will generally not be exposed in the public signatures of the module/class in which they are used. They provide a convenient way of accomplishing certain things that otherwise could not be accomplished easily -- at least not in composition with other kyo-effects.ChoiceandVar,Envwill generally be exposed across modules. However, as discussed above, when properly usedEnvreally only shows up inLayers, which means that when module1 depends on module2, module2 will not have to be aware of anyEnveffects of module1. Furthermore, by pushing theEnveffect to constructors (i.e.Layer), it is easy to support variableEnvtypes without having to refactor anything -- each constructor can have its own different dependency types.Env(most effects of this type could just be rewritten as a dependency).SyncandAsynccan be understood as fundamental effects -- they indicate that this part of the application includes side-effecting and possibly asynchronous processes. Users will not generally be annoyed by the proliferation of these effects throughout their application.STMis a good example of a less obvious effect of this type. WhileSTMcan also fall under "local use with added convenience", it is frequently used as a global/semi-global base effect. Well-designed applications often do include entire modules dealing entirely with transactional memory manipulation. In a traditional OOP codebase, such modules would generally include some transaction class in many or all of the public method signatures. Also, importantly,STMcan't be composed with side-effecting types, so it represents a separate "domain" of effects.Beta Was this translation helpful? Give feedback.
All reactions