{"id":16431480,"url":"https://github.com/dcastro/safe-buffer-monad","last_synced_at":"2026-06-10T01:31:05.426Z","repository":{"id":56877002,"uuid":"134880736","full_name":"dcastro/safe-buffer-monad","owner":"dcastro","description":null,"archived":false,"fork":false,"pushed_at":"2018-06-19T19:57:33.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-05-29T01:08:55.225Z","etag":null,"topics":["haskell","haskell-library","monad","monad-transformers"],"latest_commit_sha":null,"homepage":"http://hackage.haskell.org/package/safe-buffer-monad","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcastro.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-05-25T16:30:30.000Z","updated_at":"2020-09-25T23:48:02.000Z","dependencies_parsed_at":"2022-08-20T23:10:31.800Z","dependency_job_id":null,"html_url":"https://github.com/dcastro/safe-buffer-monad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dcastro/safe-buffer-monad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcastro%2Fsafe-buffer-monad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcastro%2Fsafe-buffer-monad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcastro%2Fsafe-buffer-monad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcastro%2Fsafe-buffer-monad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcastro","download_url":"https://codeload.github.com/dcastro/safe-buffer-monad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcastro%2Fsafe-buffer-monad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34133404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":["haskell","haskell-library","monad","monad-transformers"],"created_at":"2024-10-11T08:30:27.319Z","updated_at":"2026-06-10T01:31:05.393Z","avatar_url":"https://github.com/dcastro.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# safe-buffer-monad\n\nA monadic buffer resilient to exceptions.\n\nThe `SafeBufferMonad` typeclass models a buffer that you can write things to. If an exception is thrown,\nyou'll still be able to proccess the contents of the buffer up to the point where the computation was interrupted.\n\n```haskell\nclass Monad m =\u003e SafeBufferMonad s m | m -\u003e s where\n  readBuffer   :: m s\n  writeBuffer  :: s -\u003e m ()\n  clearBuffer  :: m s\n  modifyBuffer :: (s -\u003e s) -\u003e m ()\n```\n\nThe buffer can be run using one of these 6 functions:\n\n* `runBuffer` / `runBufferConcurrently`\n* `tryRunBuffer` / `tryRunBufferConcurrently`\n* `execBuffer` / `execBufferConcurrently`\n\n```haskell\n{-# LANGUAGE FlexibleContexts #-}\n\nimport SafeBuffer\nimport Data.List (intercalate)\n\ngo :: (SafeBufferMonad [String] m, MonadIO m) =\u003e m String\ngo = do\n  writeBuffer [\"line 1\"]\n  writeBuffer [\"line 2\"]\n  liftIO $ putStrLn \"brace for impact!\"\n  liftIO $ throwIO $ userError \"boom\"\n  writeBuffer [\"line 3\"]\n  pure \"done!\"\n\nmain = runBuffer (appendFile \"log.txt\" . intercalate \"\\n\") go\n```\n\n```plain\nλ\u003e main\nbrace for impact!\n*** Exception: user error (boom)\n\nλ\u003e :! tail log.txt\nline 1\nline 2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcastro%2Fsafe-buffer-monad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcastro%2Fsafe-buffer-monad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcastro%2Fsafe-buffer-monad/lists"}