【发布时间】:2012-09-01 10:57:00
【问题描述】:
我是Yesod Haskell的新手,非常喜欢它,但是一个月后我不得不离开它,因为我无法解决这个问题: 我有版本 yesod-core version:1.0.1.3 我按照这个例子: More Client Side Yesod: todo sample 我可以创建自己的页面并通过 json 用数据填充它 在我使用 json 添加新记录之后 但是我无法删除或更改记录,因为我找不到找回密钥的方法。 我不能使用这个系统来导出数据,如下所述:Parsing a JSON post 和 Correct way to do a “join” in persist with yesod 和 aeson-0.6.0.2: Fast JSON parsing and encoding 因为我总是收到这个错误:
Exception when trying to run compile-time code:
Data.Aeson.TH.withType: Unsupported type: TySynD Model.Elarticoli [] (AppT (ConT Model.ElarticoliGeneric) (ConT Database.MongoDB.Query.Action))
Code: deriveFromJSON (id) ''Elarticoli
如果我使用这个系统:
Elarticoli
marca Text
descrizione Text
idum Int
prezzo Double
instance FromJSON (Key id Elarticoli) where
parseJSON = fmap Key . parseJSON
instance FromJSON Elarticoli where
parseJSON (Object v) = Elarticoli
<$> v .: "marca"
<*> v .: "descrizione"
<*> v .: "idum"
<*> v .: "prezzo"
parseJSON _ = fail "Invalid Elarticoli"
postAeldatidelR :: Handler ()
postAeldatidelR = do
id <- parseJsonBody_
runDB (delete id)
sendResponseStatus status204 ()
我总是收到这个错误:
Handler/Aeldati.hs:72:12:
Ambiguous type variable `val0' in the constraint:
(PersistEntity val0) arising from a use of `delete'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `runDB', namely `(delete id)'
In a stmt of a 'do' block: runDB (delete id)
In the expression:
do { id <- parseJsonBody_;
runDB (delete id);
sendResponseStatus status204 () }
为了持久性,我使用 MongoDB。 我必须回去用Java工作吗?感谢您的帮助。
【问题讨论】: