-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why BotM has to end with an action? #41
Comments
I wrote some helpers for myself botAction :: Update -> Model -> Maybe (Maybe Action)
botAction update model = Just <$> onUpdate update model
botHandler :: Maybe Action -> Model -> Eff (Maybe Action) Model
botHandler maction model =
case maction of
Nothing -> pure model
Just action -> onAction action model
(<#) :: model -> BotM a -> Eff (Maybe action) model
m <# b = withEffect (b $> Nothing) m They don't help with extra iteration, but remove non-sense code. |
I agree, ergonomics might be slightly better, however I don't think using
Ideally that
You can use the helper |
Why? How can the framework handle this instead of user code? I can imagine
But why Separation can be achieved through
Sorry, but no, that Nothing is inevitable re-issued and triggers handleAction an extra time. |
Even if the user handles this, I think there should be a separate place for it.
The idea was that each
I do not understand what you mean by " On the other hand note that |
Well, I didn't expect an asynchronous job framework in a simple bot library. And it seems to miss exceptions.
As for me, |
When I want to handle just one message and reply to it, I have to emit NoAction after reply, and then I have to handle that NoAction. One can see in the debug log:
|
Should be fixed in https://hackage.haskell.org/package/telegram-bot-simple-0.4.
|
It looks like ending BotM with
pure NoAction
is boilerplate. As well ashandleAction NoAction = pure model
.So, an extra action is always issued.
And user Action is always ~ Maybe Action'.
At the same time,
botAction
allows for the absence of action with Maybe in its signature.Is Eff really needed? How to send a message without an extra action?
The text was updated successfully, but these errors were encountered: