{"id":18890899,"url":"https://github.com/igrep/haskell-fakepull","last_synced_at":"2025-10-30T06:43:02.012Z","repository":{"id":59152302,"uuid":"293037552","full_name":"igrep/haskell-fakepull","owner":"igrep","description":"Monad to pull from fake stream-like objects.","archived":false,"fork":false,"pushed_at":"2020-09-05T10:04:21.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-28T04:43:55.797Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igrep.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-05T08:45:54.000Z","updated_at":"2020-09-05T10:04:18.000Z","dependencies_parsed_at":"2022-09-13T11:01:05.732Z","dependency_job_id":null,"html_url":"https://github.com/igrep/haskell-fakepull","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/igrep/haskell-fakepull","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrep%2Fhaskell-fakepull","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrep%2Fhaskell-fakepull/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrep%2Fhaskell-fakepull/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrep%2Fhaskell-fakepull/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igrep","download_url":"https://codeload.github.com/igrep/haskell-fakepull/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrep%2Fhaskell-fakepull/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273812161,"owners_count":25172878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T07:58:03.800Z","updated_at":"2025-10-30T06:42:56.954Z","avatar_url":"https://github.com/igrep.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fakepull\n\nMonad to pull from fake stream-like objects.\n\n## Example\n\nSometimes you might want to test a function that uses an HTTP client object to\nget responses from some web server, without actually making the HTTP requests.\n\n```haskell\n-- BEGINNING OF EXAMPLE\n\nimport Control.Monad.IO.Class\nimport Data.IORef\nimport Data.Maybe\nimport Test.Hspec\nimport Test.Pull.Fake.IO\n\n\ndata Request = Request\n  { searchTerm :: String\n  , pageSize :: Int\n  , cursor :: Maybe String\n  } deriving (Eq, Show)\n\n\ndata Response = Response\n  { searchResult :: [String]\n  , nextCursor :: Maybe String\n  } deriving (Eq, Show)\n\n\n-- | The function you test.\n--   Call `sendRequest` repeatedly to get all paginated search results using\n--   the cursor.\nfetchAllPages :: MonadIO m =\u003e (Request -\u003e m Response) -\u003e String -\u003e m [String]\nfetchAllPages sendRequest term = go [] (Request term 3 Nothing)\n where\n  go accum req = do\n    res \u003c- sendRequest req\n    let newAccum = accum ++ searchResult res\n    case nextCursor res of\n        Just cur -\u003e do\n          let newReq = req { cursor = Just cur }\n          go newAccum newReq\n        Nothing -\u003e return newAccum\n\n\n-- | The function to make an HTTP request actually. Will be stubbed.\nsendRequestActually :: Request -\u003e IO Response\nsendRequestActually = error \"This function should be stubbed!\"\n\n-- | Simulate the `sendRequest` function that returns a different result every\n--   time.\nstubbedSendRequest :: FakeStream Response -\u003e Request -\u003e IO Response\nstubbedSendRequest stream _request =\n  -- NOTE: You may want to validate the request argument for testing.\n  --       I've omitted that for simplicity here.\n  fromJust \u003c$\u003e pull stream\n\n\nmain :: IO ()\nmain = hspec $\n  describe \"fetchAllPages\" $\n    it \"collect all results by sending requests\" $ do\n      let allResponses =\n            [ Response [\"result 1-1\", \"result 1-2\", \"result 1-3\"] $ Just \"cursor a\"\n            , Response [\"result 2-2\", \"result 2-2\", \"result 2-3\"] $ Just \"cursor b\"\n            , Response [\"result 3-1\"] Nothing\n            ]\n\n      responsesToReturn \u003c- newFakeStream allResponses\n      fetchAllPages (stubbedSendRequest responsesToReturn) \"result\" \n        `shouldReturn` concatMap searchResult allResponses\n\n-- END\n```\n\n## Related package\n\n- [fakefs](http://hackage.haskell.org/package/fakefs)\n    - This package is a variant of fakefs for stream-like objects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrep%2Fhaskell-fakepull","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figrep%2Fhaskell-fakepull","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrep%2Fhaskell-fakepull/lists"}