Skip to content

Usage of monad transformers #1441

Answered by aloslider
wujido asked this question in Q&A
Jan 30, 2025 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

I understand what louthy says like this: you don't need to use custom OptDb<A> or OptValidDb<A> types, but instead you can use IO's capabilities and existing traits for fail/alt values (in your case, Fallible is enough). So, instead of using Db<Option<Product>> when trying to query an item, you may return a specific error and catch it on the caller's side; and instead of using `Db<Validation<Error, Option>> when trying to update an item, you may return just specific Errors errors indicating what went wrong. And yes, you can not only "fast-worward" (I guess you mean "short-circuit") the computation, but also accumulate errors.
By the way, your thoughts on making custom subtypes of db opera…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@louthy
Comment options

@wujido
Comment options

@louthy
Comment options

@wujido
Comment options

@louthy
Comment options

Comment options

You must be logged in to vote
2 replies
@wujido
Comment options

@louthy
Comment options

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