Yeson.json.object 应用于太多参数
Yeson.json.object is applied to too many arguments
import Yesod
import Data.Text
data App = App
instance Yesod App
mkYesod "App" [parseRoutes|
/ Home GET
|]
getHome :: String -> Handler Value
getHome = object ["name" .= ("Adam"::Text)]
main = warpDebug 2012 App
抛出错误,
Couldn't match expected type ‘String -> Handler Value’
with actual type ‘Value’
Possible cause: ‘object’ is applied to too many arguments
In the expression: object ["name" .= ("Adam" :: Text)]
In an equation for ‘getHome’:
getHome = object ["name" .= ("Adam" :: Text)]
object
不在前奏的范围内。哪个 package/module 定义了这个?上例为什么不取键值对?
object
is not in scope in prelude. Which package/module defines this?
Why doesn't it take the key-value pair in the above case?
接受键值对就好了。错误消息告诉您 object
给了您一个 Value
,但您声明 getHome
是 String -> Handler Value
类型,而不是 Value
.
在这种情况下,"possible cause" 似乎只是误导。
import Yesod
import Data.Text
data App = App
instance Yesod App
mkYesod "App" [parseRoutes|
/ Home GET
|]
getHome :: String -> Handler Value
getHome = object ["name" .= ("Adam"::Text)]
main = warpDebug 2012 App
抛出错误,
Couldn't match expected type ‘String -> Handler Value’
with actual type ‘Value’
Possible cause: ‘object’ is applied to too many arguments
In the expression: object ["name" .= ("Adam" :: Text)]
In an equation for ‘getHome’:
getHome = object ["name" .= ("Adam" :: Text)]
object
不在前奏的范围内。哪个 package/module 定义了这个?上例为什么不取键值对?
object
is not in scope in prelude. Which package/module defines this?
Why doesn't it take the key-value pair in the above case?
接受键值对就好了。错误消息告诉您 object
给了您一个 Value
,但您声明 getHome
是 String -> Handler Value
类型,而不是 Value
.
在这种情况下,"possible cause" 似乎只是误导。