如何在ghci中检查Handler Monad中的值? [英] How does one inspect values inside the Handler Monad in ghci?

查看:137
本文介绍了如何在ghci中检查Handler Monad中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类型
Handler [也许AvailableDay]
我想检查ghci中的[Maybe AvailableDay]的内容。如何做到这一点?

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

推荐答案

不能简单地提取 Handler ,作为 Handler 实际上是一个可以取决于当前请求,会话状态等的计算。所以为了运行它,你必须提供所有这些。这将涉及使用 runHandler ,然后按 unYesodApp run 生成 Iteratee 。技术上可行,但难以置信地自己做。

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.

如果您不认为这个值取决于任何这个值,那么您应该能够重写它作为一个纯粹的计算或者在 IO monad中的一个,这应该会更容易运行。

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.

这篇关于如何在ghci中检查Handler Monad中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆