feat: make builders monadic via TelegramEx.Effect#27
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the new
TelegramEx.Effectexecution model and adapts builders to use it.Builders now accept either a raw handler context map or an existing
TelegramEx.Effect, and return an effect. This keeps the existing pipeline style while allowing builder chains to carry errors instead of raising orreturning early. For example, file-based builders can now preserve file read failures in the effect, and API request failures are also stored in the same flow.
The server no longer needs to know effect internals directly.
TelegramEx.Effect.to_result/1converts an effect back into a normal handler result, and TelegramEx.Server continues to handle FSM transitions,:ok,:pass,and errors as regular handler outcomes.
A shared
TelegramEx.Builder.put_payload/3helper was added to avoid duplicating payload mutation logic across builders.How it works now:
Effect.wrap/1, so users can start pipelines with the usual ctx.Effect.map_ctx/2.Effect.then/2.{:file, reason}.Server.handle_result/4callsEffect.to_result/1and then processes the normalized result.TelegramEx.Builder.put_payload/3.This keeps the public DX close to the old style:
but the pipeline can now safely carry errors through the builder chain.
Ready Checklist
Related Issues
Closes #21, #20