Skip to content

Prelude.Aff vs Prelude.AffMaybe #1237

Answered by louthy
Malgefor asked this question in Q&A
Discussion options

You must be logged in to vote

AffMaybe(...) allows you to return a Fin<A>, that gives you the opportunity to lift a lambda that could fail (i.e. return Fin.Succ or Fin.Fail). Aff(...) doesn't allow that, so it expects the lifted function to always succeed (i.e. it's pure).

Obviously, you could throw an exception in the Aff lifted function, so it's not entirely clear cut. However, best practice is to avoid throwing exceptions for 'known' errors (i..e. exceptions are only for exceptional events, like running out of memory).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Malgefor
Comment options

Answer selected by Malgefor
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