3 ms·
> If some functions fail with an empty Maybe and some fail with an Either and some with Error you will have to wrap all of those While this is true, the wrappi
by dllthomas 9y ago
> If some functions fail with an empty Maybe and some fail with an Either and some with Error you will have to wrap all of those
While this is true, the wrapping can be quite simple. Turning a Maybe into an Either is just a `fromMaybe (Left MyErr) Right`, and you can of course give it a name to clean it up even more.
- hota_mazi 9y agoThat particular function is tied to Maybe and Either. Good luck with that when your functions start returning all types of different monads and welcome to monad transformer hell.
- dllthomas 9y agoMaybe and Either was the topic of discussion. If you want to discuss a different example, present a different example. Attempting to speak usefully to vague generality... if your functions are returning different concrete monadic values you need to either run them and get something pure out or translate them into your current context. It's usually better practice, however, to leave the choice of monad up to the call site and only ask for the interfaces you need (MonadState, MonadReader, etc), at which point there's no call-site-local translation needed at all, you just have to make sure you're supporting the interfaces requested.