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
throws error as,
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 is not in scope in prelude. Which package/module defines this? Why doesn't it take the key-value pair in the above case?
Yesod.Json
It takes the key value pair just fine. The error message is telling you that
objectgives you aValue, but you declaredgetHometo be of typeString -> Handler Value, notValue.The "possible cause" seems to just be misleading in this case.