我正在尝试从 Yesod 的处理程序编写一个最简单的 JSON 响应,但有一些非常愚蠢的错误(显然)。我的处理程序代码是这样的:
-- HelloYesod/Handler/Echo.hs
module Handler.Echo where
import           Data.Aeson      (object, (.=))
import qualified Data.Aeson      as J
import           Data.Text       (pack)
import           Import
import           Yesod.Core.Json (returnJson)
getEchoR :: String -> Handler RepJson
getEchoR theText = do
  let json = object $ ["data" .= "val"]
  return json
错误是这样的:
Handler/Echo.hs:12:10:
    Couldn't match expected type `RepJson' with actual type `Value'
    In the first argument of `return', namely `json'
    In a stmt of a 'do' block: return json
    In the expression:
      do { let json = object $ ...;
           return json }
Build failure, pausing...