Skip to content

Help understanding the "right" way to handle IO, exceptions and nullability #1321

Answered by louthy
drk-mtr asked this question in Q&A
Discussion options

You must be logged in to vote

You're on the right track, but yeah the moment it starts feeling messy, you're likely to be veering off course (or, there's a feature from v5 that I haven't added yet!)

So, the IO<A> type is the 'raw unit of IO' in v5 language-ext. It doesn't have lots of features like Eff<A>, although it is no slouch!

Errors are handled slightly differently too. From within a liftIO your best bet (to raise errors) is to throw an exception. The code within the liftIO is supposed to be the 'messy bit' that we capture an make nice and fluffy by wrapping it in the IO type. Outside of the liftIO (once you have a real IO monad) you have the opportunity to @catch | @catchM | @catchOf the errors and handle them …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@drk-mtr
Comment options

@louthy
Comment options

Answer selected by drk-mtr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants