{"id":15010963,"url":"https://github.com/lev135/bidirectional-instances","last_synced_at":"2026-01-27T23:52:52.133Z","repository":{"id":58576164,"uuid":"531641172","full_name":"Lev135/bidirectional-instances","owner":"Lev135","description":"This package contains class for bidirectional instances and TH methods for generating instances for it.","archived":false,"fork":false,"pushed_at":"2022-09-04T16:45:36.000Z","size":48,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-23T22:55:22.673Z","etag":null,"topics":["haskell","language"],"latest_commit_sha":null,"homepage":"","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/Lev135.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":"2022-09-01T18:31:11.000Z","updated_at":"2022-09-05T09:28:13.000Z","dependencies_parsed_at":"2022-09-21T12:44:40.479Z","dependency_job_id":null,"html_url":"https://github.com/Lev135/bidirectional-instances","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lev135%2Fbidirectional-instances","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lev135%2Fbidirectional-instances/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lev135%2Fbidirectional-instances/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lev135%2Fbidirectional-instances/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lev135","download_url":"https://codeload.github.com/Lev135/bidirectional-instances/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276188,"owners_count":20912288,"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","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","language"],"created_at":"2024-09-24T19:37:54.501Z","updated_at":"2026-01-27T23:52:52.073Z","avatar_url":"https://github.com/Lev135.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"bidirectional-instances\n===\n\nThis is a haskell package to provide wrapper class and useful template haskell\ninstance-generator functions for bidirectional instances, i. e. for instance\n```hs\ninstance (A a, B b) =\u003e C (Foo a b)\n```\ndeduce not only `forall a b. (A a, B b) =\u003e C (Foo a b)`, but also\n`forall a b. C (Foo a b) =\u003e A a` and `forall a b. C (Foo a b) =\u003e B b`.\nThis behavior doesn't implemented in modern GHC version, but its very intuitive\n(and, of course, sound) if there are no overlapping instances for `C (Foo a b)`.\n\nThere was a [paper](https://arxiv.org/pdf/1906.12242.pdf), related to this \nfeature and an attempt to \n[implement it as GHC extension](https://github.com/KoenP/ghc-proposals/blob/patch-1/proposals/0000-bidirectional-instances.md).\nIn the discussion about alternatives for that extension this solution \n[was mentioned](https://github.com/KoenP/ghc-proposals/blob/patch-1/proposals/0000-bidirectional-instances.md#using-constraint-kinds),\nbut was discarded as \"decidedly nontrivial, and some boilerplate is still \nrequired, which needs to be written for every instance\".\nTo reduce these downsides, instances from this package are made more general\nand template haskell function for generating boilerplate code are provided.\nI suppose that implementation this as an compiler extension probably would be \nbetter for performance, but I don't have enough qualification to implement it.\n\nDocumentation\n---\nDetailed documentation with examples can be found in the main module \n*(Control.Bidirectional)*.\n\nUsage\n---\nAll function and classes you need to work with are exported from \n`Control.Bidirectional`.\n\nTo be implemented somewhere in the future\n---\nI'll try to make a GHC plugin to improve this solution in two directions:\n- no need for template haskell\n- more intuitive syntax\n\nMore precisely, I'd like to have the following syntax for declaring \nbidirectional instances:\n```hs\ninstance {-# BIDIRECTIONAL #-} (A a, B b) =\u003e C (Foo a b)\n```\nand `-XBidirectionalInstances` to make all instances without \n`OVERLAPS`/`OVERLAPPING`/`OVERLAPPABLE` bidirectional by default.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flev135%2Fbidirectional-instances","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flev135%2Fbidirectional-instances","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flev135%2Fbidirectional-instances/lists"}