wasp: Improve error handling in Generator - come up with monad transformer stack for Generator
Right now we just call error which is very crude, instead we should use a monad transformer stack that has ExceptT in it. Probably we will also want to combine it with ReaderT in order to pass wasp around. So this really comes down to coming up with nice monad transformer stack for Generator.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (18 by maintainers)
Links to this issue
Commits related to this issue
- feat: Adds Generator monad for more flexible error and warning handling Closes #123 — committed to wasp-lang/wasp by deleted user 2 years ago
- feat: Adds Generator monad for more flexible error and warning handling Closes #123 — committed to wasp-lang/wasp by deleted user 2 years ago
- feat: Adds Generator monad for more flexible error and warning handling (#433) Closes #123 — committed to wasp-lang/wasp by shayneczyzewski 2 years ago
Great, thanks @Martinsos for your quick take! This is super helpful and will unblock me to hopefully to get closer towards a Draft PR today (and hopefully ready for review tomorrow). I really appreciate the thoughts! 👍🏻 🚀
@shayneczyzewski thanks for this, this is very cool!
Regarding additional level of interface, so we don’t deal directly with
askbut instead we have functions on top of it -> yes, I like that very much, was considering proposing that at some point actually. I love looking at a monad like this as a type and bunch of functions on it, and whileaskis a function on it, it is a bit too close to the implementation. So I think this is a no-brainer and great approach.As for
Has...approach -> makes sense! I think you explained pros/cons in great way. The only thing I fear is that we introduce more complexity than we take away, which is not easy to judge at the moment. But it is certainly attractive, and the idea of specifying granular dependencies on type level is really attractive. This does though mean we have to define a type class for each of those. But that might be ok. Interesting interesting!Hm it seems we are slowly coming up with a gradual plan to attack this problem. It is obviously not yet completely clear, but it is shaping well for sure! Thanks for the effort, looking forward to see what you suggest next!
Did some simple experimenting locally and made it runnable here just in case anyone wants to get a feel for it all: https://replit.com/@smcnc/ReaderT-ExceptT-playground#Main.hs
Note: You can just check out the Main.hs file if you want. It won’t Run out of the box (replit quirk it seems), but if you fork and follow README directions you can get it running pretty easily.
Hey @Martinsos thanks for the example. I think planning ahead if we think we will need it, which it does sound like here, makes sense. I’m good with creating a Generator monad that is first just ExceptT! 👍🏻 Will start on it, thanks.
Think about how to handle warnings, so we may be able to do other things like show “Need to migrate” in browser when running
wasp startand Prisma schema changed. This could be handled with different error severity levels.