如何动态生成 selectFields
我正在尝试通过使用 flip
映射 mreq selectField
来动态生成 selectFields,我想知道这是否是最好的方法。
这是我的尝试。在研究了 Flip 的类型之后,我开始认为这可能是错误的方法。欢迎反馈。
[(versionRes,versionView)] <- mapM (mreq (flip (selectField "Placeholder" Nothing)))
versions
versions
的类型为 [[(Text,Text)]]
。
我认为这些错误没有说明任何有用的信息,因为如果通过这种方法可以做到这一点,那么问题就在于如何获得正确的类型。我很难做到这一点,并且不确定这种方法是否有解决方案。
供参考的是 mreq
, 翻转
和 selectField
。
嗯,这是我的下一次尝试。
[(versionRes,versionView)] <- mapM (flip mreq selectField ("Placeholder" Nothing)) versions
我正在尝试让 mreq 像这样工作
mreq "Placeholder" Nothing (选择字段 [(文本),(文本)])
I'm trying to dynamically generate selectFields by mapping over mreq selectField
using flip
, and I'm wondering if this is the best way.
This is my attempt. After studying flip's type I'm starting to think this may be the wrong approach. Feedback welcome.
[(versionRes,versionView)] <- mapM (mreq (flip (selectField "Placeholder" Nothing)))
versions
versions
's type is [[(Text,Text)]]
.
I don't think the errors say anything useful as, if this is possible with this approach, it's a matter of getting the types right. I'm having difficulty doing that, and am not sure there's a solution with this approach.
For reference here are the type definitions of mreq
, flip
and selectField
.
Well, this is my next attempt.
[(versionRes,versionView)] <- mapM (flip mreq selectField ("Placeholder" Nothing)) versions
I'm trying to get mreq to work like this
mreq "Placeholder" Nothing (selectField [(Text),(Text)])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得出的结论是,翻转是不切实际的,即使它可能是可行的。
我正在做这样的事情。
versionInfo <- mapMgenerateVersionSelectFields [[(Text),(Text)]]
generateVersionSelectFields version = do
mreq (selectField version) "Placeholder" Nothing
我将其留在这里,以便可能会得到改进或出现替代方法。
I have come to the conclusion that flip just isn't practical, even if it might be possible.
I'm doing something like this instead.
versionInfo <- mapM generateVersionSelectFields [[(Text),(Text)]]
generateVersionSelectFields version = do
mreq (selectField version) "Placeholder" Nothing
I leave this here so that maybe it gets improved or an alternative approach appears.