{"id":16843981,"url":"https://github.com/tobgu/peds","last_synced_at":"2025-03-22T05:31:18.548Z","repository":{"id":57496660,"uuid":"79030712","full_name":"tobgu/peds","owner":"tobgu","description":"Type safe persistent/immutable data structures for Go","archived":false,"fork":false,"pushed_at":"2021-04-23T19:14:47.000Z","size":115,"stargazers_count":63,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T08:48:10.148Z","etag":null,"topics":["datastructures","functional","golang","immutable"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/tobgu.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":"2017-01-15T12:16:46.000Z","updated_at":"2024-12-31T09:31:06.000Z","dependencies_parsed_at":"2022-09-03T02:30:15.792Z","dependency_job_id":null,"html_url":"https://github.com/tobgu/peds","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/tobgu%2Fpeds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobgu%2Fpeds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobgu%2Fpeds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobgu%2Fpeds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobgu","download_url":"https://codeload.github.com/tobgu/peds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912800,"owners_count":20530764,"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":["datastructures","functional","golang","immutable"],"created_at":"2024-10-13T12:54:20.430Z","updated_at":"2025-03-22T05:31:18.036Z","avatar_url":"https://github.com/tobgu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Statically type safe persistent/immutable/functional data structures for Go.\n\nInspired by Clojures data structures and the work done in\n[Pyrsistent](https://www.github.com/tobgu/pyrsistent) for Python.\n\nThis is an experiment in how close to generics that code generation can take\nyou. There's currently a vector, a slice, a map and a set implemented.\n\n## What's a persistent data structure?\nDespite their name persistent data structures usually don't refer to\ndata structures stored on disk. Instead they are immutable data\nstructures which are copy-on-write. Eg. whenever you mutate a persistent\ndata structure a new one is created that contains the data in the\noriginal plus the mutation while the original is left untouched.\n\nTo make this reasonably efficient, \"structural sharing\" is used between\nthe data structures. Here's a good introduction to how this is done in\nClojure:\nhttp://hypirion.com/musings/understanding-persistent-vector-pt-1\n\n## Installation\n`go get github.com/tobgu/peds/cmd/peds`\n\n## Usage\n```\nGenerate statically type safe code for persistent data structures.\n\nUSAGE\npeds\n\nFLAGS        EXAMPLE\n  -file      path/to/file.go\n  -imports   import1;import2\n  -maps      Map1\u003cint,string\u003e;Map2\u003cfloat,int\u003e\n  -pkg       package_name\n  -sets      Set1\u003cint\u003e\n  -vectors   Vec1\u003cint\u003e\n```\n\n## Examples\n\nThere are a couple of generated example collections in\n[examples/collections.go](https://github.com/tobgu/peds/blob/master/examples/collections.go).\n\nThe `go:generate` command used can be found in [examples/types.go](https://github.com/tobgu/peds/blob/master/examples/types.go).\n\nThis illustrates the core usage pattern:\n```\n//go:generate peds -vectors=IntVector\u003cint\u003e -pkg=my_collections -file=collections/my_collections_gen.go\n\n// Create a new vector\nv := my_collections.NewIntVector(1, 2, 3)\n\n// Create a copy of v with the first element set to 55, v is left untouched.\nv2 := v.Set(0, 55)\n```\n\n## Godoc\n\n#### Generic types\nhttps://godoc.org/github.com/tobgu/peds/internal/generic_types\n\n#### Generated examples\nhttps://godoc.org/github.com/tobgu/peds/examples\n\n## Experiences\n\nThere's an [experience report](https://github.com/tobgu/peds/blob/master/experience_report.md) based on the implementation of this library.\n\n## Caveats\n* Even though the data structures are immutable by most means it is not\n  possible to use them as keys in hash maps for example. This is because\n  they internally make use of slices, which are not comparable in Go.\n\n## Possible improvements\n* Investigate implementing the Map as a CHAMP tree.\n* Introspection of the contained types possible to\n  refine the hash functions?\n* Get rid of Python dependency for developing peds (not needed to build or use peds).\n\n## Regenerate templates and run tests\n`make test`\n\n## Want to contribute?\nGreat! Write an issue and let the discussions begin! Then file a PR!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobgu%2Fpeds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobgu%2Fpeds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobgu%2Fpeds/lists"}