Skip to content
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

[New topic] Errors and exceptions #1

Open
Martinsos opened this issue May 4, 2021 · 5 comments
Open

[New topic] Errors and exceptions #1

Martinsos opened this issue May 4, 2021 · 5 comments

Comments

@Martinsos
Copy link
Member

No description provided.

@Martinsos Martinsos changed the title New topic: Errors and exceptions [New topic] Errors and exceptions May 4, 2021
@soupi
Copy link

soupi commented Nov 4, 2021

lhbg-book.link has a few chapters on Either, ExceptT, and exceptions.

@Martinsos
Copy link
Member Author

Thanks for sharing, I find especially interesting the one about exceptions since I still I need to understand that part better!

What are your thoughts about recommendation from https://www.fpcomplete.com/haskell/tutorial/exceptions/ to use UnliftIO.Exception instead of Control.Exception?

@soupi
Copy link

soupi commented Nov 8, 2021

I believe fpco understand exceptions better than me. I've tried covering the basics that are available in base and focus on IO.
It is also likely that understanding the regular Control.Exception will make using UnliftIO.Exception easier anyway, because they have very similar APIs and concepts.

@Martinsos
Copy link
Member Author

Martinsos commented Jan 15, 2023

What is also somewhat confusing is when to use Either vs throwing an IO exception.
Interesting discussion here:
https://www.reddit.com/r/haskell/comments/z5ezoa/why_network_requests_throw_exceptions_instead_of/ .

The summary is somewaht in direction of: use Either when you want consumer of function to be very aware of what you are returning and explicitly handle it, vs use IO exception when you want to be more implicit and just let him handle those exceptions only if they really want to.
But I don't think this is final explanation, I think there is more to it, this was just what I quickly got from it.

@soupi
Copy link

soupi commented Mar 22, 2023

As a general approach when following the 'functional core, imperative shell' pattern, I usually use Either/Except in the functional core, and exceptions in the imperative shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants