我想在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