Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:01:24+00:00 2026-06-09T10:01:24+00:00

{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, ScopedTypeVariables #-} module Db ( couchTest ) where import Control.Monad.IO.Class

  • 0
{-# 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

error

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) How do you add an instance declaration for monad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl IO m0?

2) Is it possible to create attachments with couchdb-conduit?

3) Is there a example of using couchdb directly with http package, basically to see how much code it takes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:01:26+00:00Added an answer on June 9, 2026 at 10:01 am

    Might be better to split your question up since you’re asking three different things. As far as #1 goes, no new instance is required for MonadBaseControl. Add type signatures to remove the ambiguity and it compiles straight away:

    {-# LANGUAGE DeriveDataTypeable, FlexibleContexts,
                 OverloadedStrings, ScopedTypeVariables #-}
    module Db (
        couchTest
    ) where
    
    import Control.Monad.IO.Class (MonadIO, liftIO)
    import Control.Monad.Trans.Resource (MonadThrow, MonadUnsafeIO)
    import Control.Monad.Trans.Control (MonadBaseControl)
    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
      :: (MonadIO m, MonadUnsafeIO m, MonadThrow m, MonadBaseControl IO m)
      => m ()
    -- couchTest :: IO () -- restricting it to IO is also an option
    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
    

    I had GHC come up with the constraint list for me by enabling the NoMonomorphismRestriction language pragma and running the following in GHCi. You can also leave the NMR flag set in many cases instead of adding explicit signatures, but I prefer explicit signatures.

    *Db> :info couchTest 
    couchTest ::
      (MonadIO m, Control.Monad.Trans.Resource.MonadUnsafeIO m,
       Control.Monad.Trans.Resource.MonadThrow m,
       MonadBaseControl IO m) =>
      m ()
        -- Defined at /tmp/cdb.hs:21:5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GHC has a few language flags, such as DeriveFunctor , DeriveDataTypeable etc., which enable
Language: PHP / Using Class Upload by Colin Verot About: Multiple Uploading The code
Language: OO PHP 5+ DB: MySQL I am trying to insert data from a
Language FAQ says import scala.collection.mutable.{_, Map => _, Set => _} should import all
C language has a data-type float . Some machines have a floating point processor
A language has not array as a data type but it has stack as
/*language C code*/ #include windows.h typedef struct object_s { SRWLOCK lock; int data; }
I have tried to implement the rectangle problem using OOHaskell. {-# LANGUAGE EmptyDataDecls, DeriveDataTypeable,
Language is C#. Say i have overridden method in class A class A:B {
Language: PHP / MySQL I am going out of my mind, I really have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.