Каков тип настраиваемых полей, содержащих вызовы widgetFile?

Если указание 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")

person liszt    schedule 11.10.2013    source источник
comment
Можете ли вы рассказать, чего вы пытаетесь достичь, и прикрепить fancy.hamlet исходный код?   -  person lambdas    schedule 12.10.2013
comment
Я пытаюсь создать собственный Field (fancyTextField) для последующего использования в Forms. Содержимое fancy.hamlet может быть любым, например. <div>Hello.   -  person liszt    schedule 12.10.2013


Ответы (1)


Я полагаю, вы хотите использовать Handler вместо m.

person Michael Snoyman    schedule 12.10.2013