How does one inspect values inside the Handler Monad in ghci?

♀尐吖头ヾ 提交于 2019-12-11 16:52:14

问题


I have a type Handler [Maybe AvailableDay] I would like to inspect the contents of [Maybe AvailableDay] in ghci. How do I do that?


回答1:


You cannot simply extract the "contents" of a Handler, as a Handler is really a computation which can depend on the current request, session state and so on. So in order to run it, you'd have to feed it all of that. This would involve using runHandler, followed by unYesodApp, and run on the resulting Iteratee. Technically possible, but incredibly messy to do on your own.

If you don't think the value is depending on any of that, then you should be able to rewrite it as a pure computation or one in the IO monad, which should be a lot simpler to run.



来源:https://stackoverflow.com/questions/8043437/how-does-one-inspect-values-inside-the-handler-monad-in-ghci

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