gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 07:05:27 24 4
gpt4 key购买 nike

如果给 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")

最佳答案

我相信您想使用 Handler 代替 m

关于haskell - 包含对 widgetFile 的调用的自定义字段的类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19319156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com