Using the ExceptT monad with different error types

倖福魔咒の 提交于 2019-12-11 07:53:17

问题


I decided to refactor this code https://github.com/kototama/screepy/blob/21b5b12bc16f9c4e5ee699ca319fd6c6466d1421/src/Screepy/Auth.hs which deals with IO, Either and Maybe values with an ExceptT monad.

Here is my refactored code: https://github.com/kototama/screepy/blob/dc2dcf5abfd72e29dd018c4a7377a02a1fa097a9/src/Screepy/Auth.hs

This does not seem much of an improvement to me. What can I do to improve this code?

And in general how to deal with code calling libraries that return different types for errors (Either, Maybe, Exception, Result etc).

In my case I'm dealing with exceptions (wreq), Maybe values (lens with aeson) and Either values (aeson)!

来源:https://stackoverflow.com/questions/27051454/using-the-exceptt-monad-with-different-error-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!