-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
IO Monad #265
Comments
Hi, and thanks for the interesting question! 🙂 I don't have a solution at hand, but I'll think about it and get back to you. |
Could you explain in a bit more detail what you'd like to archive (or maybe show a minimal example in Haskell)? Do you want |
I was thinking of something like the below:
If the log function fails and throws, I would like the logging failed information to be transported in addition to the result<string, string>. I suppose one way would be just to change the return type of |
Ok, so if I understand correctly, no matter if the logging fails or not, you want your actual function to be executed nonetheless. Because otherwise, it would just be simple monadic composition, which could be achieved using things like But in your case, we can have the following possible results:
Thus, just thinking about the types for now, we need a return type for your final (composed) function able to represent all those states. For now, we have:
So the result of the new
Thus we could have
Is the above going in the right direction, or do you intend something else? |
yes what you outlined makes sense! |
Hi @Dobiasd,
I worked through your Udemy functional programming course and found functional programming and
fplus
to be highly interesting. Am currently attempting to refactor some code and am just wondering if there is a way to model IO monads usingfplus
?I have a function that is currently as such:
However, I would like to add some logging at the start of the function. This would change the return type since logging is an
IO
action which may fail, but not too sure how it can be done usingfplus
.Be great if I could get your advice :)
The text was updated successfully, but these errors were encountered: