{"id":22117710,"url":"https://github.com/prosumma/haskellpg","last_synced_at":"2025-10-14T20:16:14.501Z","repository":{"id":63773013,"uuid":"502518797","full_name":"Prosumma/HaskellPG","owner":"Prosumma","description":"A simple wrapper around Database.PostgreSQL.Simple","archived":false,"fork":false,"pushed_at":"2023-07-01T22:14:18.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T04:28:57.707Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Prosumma.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-12T04:33:08.000Z","updated_at":"2022-06-12T04:38:44.000Z","dependencies_parsed_at":"2024-12-02T08:04:00.850Z","dependency_job_id":null,"html_url":"https://github.com/Prosumma/HaskellPG","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Prosumma/HaskellPG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHaskellPG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHaskellPG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHaskellPG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHaskellPG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prosumma","download_url":"https://codeload.github.com/Prosumma/HaskellPG/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHaskellPG/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021014,"owners_count":26086947,"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-10-14T02:00:06.444Z","response_time":60,"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-12-01T13:38:42.335Z","updated_at":"2025-10-14T20:16:14.466Z","avatar_url":"https://github.com/Prosumma.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Piggy\n\nPiggy is a tiny little Haskell library that makes Database.PostgreSQL.Simple just a tiny bit easier to work with. It also facilitates easier unit testing. \n\nIt uses the [Operational monad](https://hackage.haskell.org/package/operational-0.2.3.5/docs/Control-Monad-Operational.html) and a simple typeclass:\n\n```haskell\nclass Monad m =\u003e MonadPG m where\n  interpret :: PGDSL a -\u003e m a\n  withTransaction :: m a -\u003e m a\n  withTransaction t = t\n```\n\nA default interpreter \u0026mdash; `interpg` \u0026mdash; that talks to a Postgres database is provided, as is `PG`, a default implementation of `MonadPG` that actually talks to a database using `interpg`. \n\n```haskell\ninstance MonadPG PG where \n  interpret = interpg\n  withTransaction transact = withPostgresTransaction $ flip withPG transact \n```\n\nIn unit tests, it's relatively straightforward to replace actual database access with stubs.\n\n```haskell\ngetPatients :: MonadPG m =\u003e m [Patient]\ngetPatients = interpret $ singleton (Query_ \"SELECT * FROM patients\")\n\npatients :: [Patient]\n-- etc.\n\ninterstubs :: Monad m =\u003e PGDSL a -\u003e m a\ninterstubs m = case view m of\n  (Query_ \"SELECT * FROM patients\") :\u003e\u003e= k -\u003e return patients \u003e\u003e= interstubs . k\n  -- etc.\n\nnewtype PGStub a = PGStub a deriving (Functor, Applicative, Monad)\n\n-- If `getPatients` is called with `PGStub`, it will be interpreted with\n-- interstubs and no actual database access will occur. In fact, the\n-- function is actually pure because it does not require `MonadIO`.\ninstance MonadPG PGStub where\n  interpret = interstubs\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprosumma%2Fhaskellpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprosumma%2Fhaskellpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprosumma%2Fhaskellpg/lists"}