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

  • SEARCH
  • Home
  • 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 6839269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:41:55+00:00 2026-05-26T23:41:55+00:00

I’m trying to access mongo using the mongodb haskell drivers (the snap driver appears

  • 0

I’m trying to access mongo using the mongodb haskell drivers (the snap driver appears to be broken for snap > 0.5) in splice.

This is as far as I’ve got so far:

testSplice :: Splice AppHandler
testSplice = do
  record <- liftIO $ do
    pipe <- runIOE $ connect (host "127.0.0.1") 
    results <- access pipe master "db" (find $ select [] "coll")
    close pipe
    rest result

  return $ [TextNode $ T.pack $ show $ records]

I understand that I need to use liftIO there, as the mongo action occurs inside an IO monad, and I want to pull that back out. Where my understanding breaks down is the result of compiling that splice:

Couldn't match expected type `IO a0'
    with actual type `Action m0 [Database.MongoDB.Document]'

I’m sorry to post a “Send me the codes plz” question, but I’m at loss: where am I going wrong, and how do I make this work?

  • 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-05-26T23:41:56+00:00Added an answer on May 26, 2026 at 11:41 pm

    Here is your function annotated with type signatures. I think this makes it
    pretty clear where the problem lies.

    testSplice :: Splice AppHandler
    testSplice = do
      record <- liftIO $ do
        pipe <- runIOE $ connect (host "127.0.0.1") -- :: IO Pipe
        results <- access pipe master "db" (find $ select [] "coll")
        -- ^ :: IO (Either Failure Cursor)
        close pipe -- :: IO ()
        rest result -- :: Action m [Document]
    
      return $ [TextNode $ T.pack $ show $ records]
    

    Everything inside the “liftIO $ do” block must be an IO action. The last line
    “rest result” is not. One solution is to prepend that line with ‘access pipe
    master “db”‘ just like you’ve done with find. Another solution is to avoid
    calling “access pipe…” twice and replace the find line with the following:

    result <- access pipe master "db" (find (select [] "coll") >>= rest)
    

    Then replace the “rest result” line with “return result”

    What Daniel says about the find line not needing liftIO is correct, but in
    this case it doesn’t matter because IO has a MonadIO instance. So it’s probably just as easy to keep all the liftIO stuff in one block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.