{"id":16334854,"url":"https://github.com/ncfavier/jq-optics","last_synced_at":"2026-02-16T20:35:26.897Z","repository":{"id":188260238,"uuid":"678396018","full_name":"ncfavier/jq-optics","owner":"ncfavier","description":"👓 A toy jq implementation using optics","archived":false,"fork":false,"pushed_at":"2025-01-29T21:13:37.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-08T21:14:57.708Z","etag":null,"topics":["jq","lens"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncfavier.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-14T13:05:28.000Z","updated_at":"2025-01-29T21:13:41.000Z","dependencies_parsed_at":"2023-08-14T15:42:30.966Z","dependency_job_id":"35650e91-7dcd-4f73-9416-50854c2c7055","html_url":"https://github.com/ncfavier/jq-optics","commit_stats":null,"previous_names":["ncfavier/jq-optics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ncfavier/jq-optics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncfavier%2Fjq-optics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncfavier%2Fjq-optics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncfavier%2Fjq-optics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncfavier%2Fjq-optics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncfavier","download_url":"https://codeload.github.com/ncfavier/jq-optics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncfavier%2Fjq-optics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29517617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T18:37:19.720Z","status":"ssl_error","status_checked_at":"2026-02-16T18:36:46.920Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["jq","lens"],"created_at":"2024-10-10T23:39:28.135Z","updated_at":"2026-02-16T20:35:26.871Z","avatar_url":"https://github.com/ncfavier.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jq-optics\n\nA toy implementation of the [jq](https://jqlang.github.io/jq/) language using optics.\n\n```haskell\njq :: Env -\u003e Filter -\u003e IndexedJourney' Path Value Value\n```\n\nA [traversal](https://hackage.haskell.org/package/lens-5.2.2/docs/Control-Lens-Combinators.html#t:Traversal) is a view of several disjoint targets in a data structure. Traversals obey laws that ensure the same target can't be visited twice, and are hard to compose side-by-side. Journeys are lawless traversals that are allowed to visit the same target multiple times, so that all the targets are updated sequentially. This allows representing jq filters as monomorphic journeys on JSON values.\n\nIn the [CPS / van Laarhoven representation](https://www.twanvl.nl/blog/haskell/cps-functional-references) of optics, journeys are obtained by promoting Traversal's constraint from `Applicative` to `Monad` (and the indexed variant is obtained as usual):\n\n```haskell\ntype Journey s t a b = forall m. Monad m =\u003e (a -\u003e m b) -\u003e s -\u003e m t\ntype IndexedJourney i s t a b = forall p m. (Indexable i p, Monad m) =\u003e p a (m b) -\u003e s -\u003e m t\n```\n\nMore concretely, `Journey s t a b` is isomorphic to `s -\u003e Free (PStore a b) t`, where `Free` is the free monad construction and\n\n```haskell\ndata PStore a b t = PStore a (b -\u003e t)\n```\n\nSo a journey takes an initial value and produces a series of \"interaction points\" that each produce a value (and possibly an index) and expect a replacement value, and in the end returns a final value that is the result of performing the replacements on the initial value. Journeys are composed side-by-side straightforwardly using `(\u003e=\u003e)`. Every traversal is a journey, and every journey is a setter, but journeys have no subtyping relationship with folds. Most of the lens combinators for folds have to be reimplemented and they behave slightly differently.\n\n\u003e [!NOTE]\n\u003e This project does not aim to be an *exact* clone of jq; in fact, the implementation departs from jq's in several ways:\n\u003e - Assignment is sequential, i.e. `(a, b) = c` is equivalent to `(a = c) | (b = c)`. See `[0, 2, 3] | (.[.[0]], .[.[0]]) = 1`. On the other hand, this means that `.[a, b]` is not in general equivalent to `.[a], .[b]`.\n\u003e - `|=` has cartesian product semantics instead of jq's behaviour, which is to take the first produced value, or delete the entry if no values are produced.\n\u003e - Assigning to a non-path-expression is a no-op instead of an error.\n\u003e\n\u003e Also, there's no parser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncfavier%2Fjq-optics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncfavier%2Fjq-optics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncfavier%2Fjq-optics/lists"}