{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, ScopedTypeVariables #-}
module Db (
couchTest
) where
import Control.Monad.IO.Class (liftIO)
import Data.ByteString (ByteString)
import Data.Generics (Data, Typeable)
import Database.CouchDB.Conduit
import Database.CouchDB.Conduit.Generic
conn :: CouchConnection
conn = def {couchLogin = "admin", couchPass = "admin"}
data D = D { f1 :: Int, f2 :: String } deriving (Show, Data, Typeable)
couchTest = runCouch conn $ do
rev1 <- couchPut "mydb" "my-doc1" "" [] $ D 123 "str"
rev2 <- couchPut "mydb" "my-doc1" rev1 [] $ D 1234 "another"
(rev3, d1 :: D) <- couchGet "mydb" "my-doc1" []
liftIO $ print d1
couchPut' "mydb" "my-doc1" [] $ D 12345 "third" -- notice - no rev
rev3 <- couchRev "mydb" "my-doc1"
couchDelete "mydb" "my-doc1" rev3
エラー
No instance for (monad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl
IO m0)
arising from a use of `couchPut'
Possible fix:
add an instance declaration for
(monad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl
IO m0)
In the expression: couchPut "mydb" "my-doc1" "" []
In a stmt of a 'do' block:
rev1 <- couchPut "mydb" "my-doc1" "" [] $ D 123 "str"
In the second argument of `($)', namely
`do { rev1 <- couchPut "mydb" "my-doc1" "" [] $ D 123 "str";
rev2 <- couchPut "mydb" "my-doc1" rev1 [] $ D 1234 "another";
(rev3, d1 :: D) <- couchGet "mydb" "my-doc1" [];
liftIO $ print d1;
.... }'
1)のインスタンス宣言をどのように追加しますmonad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl IO m0
か?
2)couchdb-conduitを使用してアタッチメントを作成することは可能ですか?
3)基本的にどのくらいのコードが必要かを確認するためにhttpパッケージでcouchdbを直接使用する例はありますか?