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 8529037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:56:18+00:00 2026-06-11T08:56:18+00:00

I’ve been wondering what methods (if any) are used for testing Haskell applications that

  • 0

I’ve been wondering what methods (if any) are used for testing Haskell applications that do requests over the network? Coming from Ruby land, I’ve been searching for anything that can either stub or “simulate” network calls for the purpose of testing Haskell functions. I’m particularly interested in a “VCR”-like solution (e.g.: https://github.com/myronmarston/vcr), as it seems to be the most viable option, IMHO.

So, I want to be able to record network request/response pairs once and then reuse these records for the subsequent tests. I have come up with my own simplistic concoction that starts a web server (warp) before the tests, serving prerecorded responses, but I have to point all URLs within the application to “localhost”. I presume, this is not always possible to replace all URLs within the application. Although I’m quite happy with my own setup described above (and would like to make a dedicated testing tool/framework “plugin” from it later), but I’d rather not reinvent the wheel.

  • 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-11T08:56:19+00:00Added an answer on June 11, 2026 at 8:56 am

    Check out Control.Proxy.Tutorial. If you can write a Proxy wrapper around your type, then you can easily swap out the test interface and a real interface like this:

    client <-< simulatedServer
    
    client <-< realServer
    

    Edit: To answer your question in the comment, you use a Server to write a wrapper around your simpleHTTP requests:

    realServer
     :: HStream ty => Request ty -> Server (Request ty) (Result (Response ty)) IO r
    realServer = foreverK $ \req -> do
        result <- lift $ simpleHTTP req
        respond result
    

    The simulated server would look like:

    simulatedServer
     :: (Monad m, HStream ty)
     => Request ty -> Server (Request ty) (Result (Response ty)) m r
    simulatedServer = foreverK $ \req -> do
        result <- lift $ simulatedRequest req
        respond result
    

    And your client would look like:

    client
     :: (Monad m, HStream ty) => () -> Client (Request ty) (Result (Response ty)) m r
    client () = forever $ do
        let req = <something>
        result <- request req
        lift $ doSomethingWith result
    

    Then you can test the real server and fake server using:

    -- Test the real server
    main = runSession $ client <-< realServer
    
    -- Test the fake server
    main = runSession $ client <-< simulatedServer
    

    The client and simulatedServer are polymorphic in the base monad only because I don’t know what base monad they would use for your testing. The only requirement is that the two things you compose have the same base monad or that at least one is polymorphic in the base monad.

    • 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 am currently running into a problem where an element is coming back from
I have a jquery bug and I've been looking for hours now, I can't
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
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

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.