Yeson.json.object应用于太多参数

时间:2015-05-07 06:07:22

标签: haskell yesod classy-prelude

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不在前奏范围内。哪个包/模块定义了这个?为什么不采用上述情况下的键值对?

1 个答案:

答案 0 :(得分:2)

  

Parse.User()不在前奏范围内。哪个包/模块定义了这个?

Yesod.Json

  

为什么不采用上述情况下的键值对?

它需要键值对就好了。错误消息告诉您object为您提供了object,但您声明Value属于getHome类型,而不是String -> Handler Value

在这种情况下,“可能的原因”似乎只是误导。