首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么类型的自定义字段包含对widgetFile的调用?

什么类型的自定义字段包含对widgetFile的调用?
EN

Stack Overflow用户
提问于 2013-10-11 13:17:11
回答 1查看 88关注 0票数 4

如果给fancyTextField一个显式类型会解决这个问题,我应该给它哪种类型?它期望以Field m Text的形式出现一些东西,但我不知道m应该用什么来代替。

以下是错误消息:

代码语言:javascript
复制
Couldn't match type `HandlerSite m0' with `App'
The type variable `m0' is ambiguous
Possible cause: the monomorphism restriction applied to the following:
  fancyTextField :: Field m0 Text
    (bound at Widget/Input/Text.hs:13:1)
Probable fix: give these definition(s) an explicit type signature
Expected type: [Text]
               -> [FileInfo]
               -> m0 (Either (SomeMessage (HandlerSite m0)) (Maybe Text))
  Actual type: [Text]
               -> [FileInfo] -> m0 (Either (SomeMessage App) (Maybe Text))
In the `fieldParse' field of a record
In the expression:
  Field
    {fieldParse = parseHelper $ Right, fieldView = textInput,
     fieldEnctype = UrlEncoded}
In an equation for `fancyTextField':
    fancyTextField
      = Field
          {fieldParse = parseHelper $ Right, fieldView = textInput,
           fieldEnctype = UrlEncoded}

这是密码:

代码语言:javascript
复制
module Widget.Input.Text where

import Import

-- This is text Field calling the textInput widget below.
fancyTextField = Field {
  fieldParse = parseHelper $ Right,
  fieldView = textInput,
  fieldEnctype = UrlEncoded
}

type FieldWidget =
     Text             -- Id.
  -> Text             -- Name.
  -> [(Text, Text)]   -- Attributes.
  -> Either Text Text -- Value.
  -> Bool             -- Required?
  -> Widget

textInput :: FieldWidget
textInput i name attrs val req = do
  -- The following works:
  -- [whamlet|<div>Test!|]

  -- But the following doesn't!
  $(widgetFile "fancy")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-12 17:31:29

我相信你想用Handler代替m

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19319156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档