我想在Yesod中创建一个自定义字段,它是一个带双精度数组的JSON数组的文本字段。但是我不断收到类型错误。我现在的尝试是:Yesod类型的自定义字段[双]
doubleListField :: RenderMessage master FormMessage => Field sub master [Double]
doubleListField = Field
{ fieldParse = parseHelper $ Right . decodeUtf8 . parse json
, fieldView = \theId name attrs val isReq -> toWidget [hamlet|
$newline never
<input id="#{theId}" name="#{name}" *{attrs} type="number" :isReq:required="" value="Hey">
|]
}
(正确的空格中发现:https://gist.github.com/4394850)
我目前正在与失败:
Couldn't match expected type `Data.ByteString.Internal.ByteString'
with actual type `[Text]
-> m0 (Either (SomeMessage master0) (Maybe Text))'
In the second argument of `($)', namely `parseHelper $ Right'
In the `fieldParse' field of a record
In the expression:
Field
{fieldParse = parse json $ parseHelper $ Right,
fieldView = \ theId name attrs val isReq
-> toWidget (\ _render_a5Cg -> ...)}
的FieldView我修改,我知道如何去说但我关于fieldParse应该如何看起来很尴尬。谢谢!
能编辑您的代码段请在这里有正确的缩进/空格? – Windle
当然,我会再给它一次,但链接的要点是正确的。 – rortian