4

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

这是错误消息:

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}

这是代码:

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")
4

1 回答 1

3

我相信你想Handlerm.

于 2013-10-12T17:31:29.693 回答