{"id":16188978,"url":"https://github.com/fogfish/golem","last_synced_at":"2025-04-10T01:09:41.928Z","repository":{"id":39669161,"uuid":"220327062","full_name":"fogfish/golem","owner":"fogfish","description":"pure functional and generic programming for Go","archived":false,"fork":false,"pushed_at":"2025-04-02T16:15:03.000Z","size":1370,"stargazers_count":48,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T01:09:37.084Z","etag":null,"topics":["algebraic-data-types","functional-programming","golang","golang-generics"],"latest_commit_sha":null,"homepage":"","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/fogfish.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":"2019-11-07T20:53:36.000Z","updated_at":"2025-04-08T13:21:19.000Z","dependencies_parsed_at":"2023-11-11T13:30:06.856Z","dependency_job_id":"d04e79c6-0a42-488f-8d49-56b19b266a72","html_url":"https://github.com/fogfish/golem","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgolem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgolem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgolem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgolem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fogfish","download_url":"https://codeload.github.com/fogfish/golem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137886,"owners_count":21053775,"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":["algebraic-data-types","functional-programming","golang","golang-generics"],"created_at":"2024-10-10T07:33:04.736Z","updated_at":"2025-04-10T01:09:41.908Z","avatar_url":"https://github.com/fogfish.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./doc/golem.svg\" height=\"240\" /\u003e\n  \u003ch3 align=\"center\"\u003eGolem\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\u003cstrong\u003e\"Scrap Your Boilerplate\" for Go\u003c/strong\u003e\u003c/p\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003c!-- Build Status  --\u003e\n    \u003ca href=\"https://github.com/fogfish/golem/actions/\"\u003e\n      \u003cimg src=\"https://github.com/fogfish/golem/workflows/build/badge.svg\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub --\u003e\n    \u003ca href=\"http://github.com/fogfish/golem\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/last-commit/fogfish/golem.svg\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Coverage --\u003e\n    \u003ca href=\"https://coveralls.io/github/fogfish/golem?branch=main\"\u003e\n      \u003cimg src=\"https://coveralls.io/repos/github/fogfish/golem/badge.svg?branch=main\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Go Card --\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/fogfish/golem\"\u003e\n      \u003cimg src=\"https://goreportcard.com/badge/github.com/fogfish/golem\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n  \u003ctable align=\"center\"\u003e\n    \u003cthead\u003e\u003ctr\u003e\u003cth\u003esub-module\u003c/th\u003e\u003cth\u003edoc\u003c/th\u003e\u003cth\u003eabout\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n    \u003ctbody\u003e\n    \u003c!-- Module duct --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./duct/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=duct/*\"/\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/duct\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-duct-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Metaprogramming of computations \n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c!-- Module hseq --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./hseq/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=hseq/*\"/\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/hseq\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-hseq-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Heterogenous sequence of types\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c!-- Module optics --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./optics/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=optics/*\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/optics\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-optics-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Composable getters and setters (lenses) for manipulating data structures \n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c!-- Module pipe --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./pipe/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=pipe/*\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/pipe\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-pipe-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Type safe channels and data pipeline combinator.\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c!-- Module pure --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./pure/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=pure/*\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/pure\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-pure-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Generic purely functional abstractions (e.g. HKT, Monoid, etc).\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c!-- Module trait --\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003ca href=\"./trait/\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/golem?label=mod\u0026style=flat-square\u0026filter=trait/*\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ca href=\"https://pkg.go.dev/github.com/fogfish/golem/trait\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/doc-trait-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" /\u003e\n    \u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n    Generic behavior traits.\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/p\u003e\n\n--- \n\n\u003e His dust was \"kneaded into a shapeless husk.\"\n\n\u003e You could do this with a macro, but...\n\u003e the best macro is a macro you don't maintain\n\n**Golem** is a purely functional and generic programming library for Go. It has its origins in [Purely Functional Data Structures](./doc/okasaki.pdf) by Chris Okasaki, and implements various functional abstractions and patterns, deals with [scrap your boilerplate](https://www.microsoft.com/en-us/research/publication/scrap-your-boilerplate-with-class/) and benefits from the experience of other functional languages, primary Scala, Haskell and also heavily inspired by the Erlang library [datum](https://github.com/fogfish/datum). Golem is testing the limits of functional abstractions in Go.\n\n\n## Inspiration\n\n[Functional Programming](https://en.wikipedia.org/wiki/Functional_programming) is a declarative style of development that uses side effect free functions to express the solution of the problem domain. The [core concepts](http://www.se-radio.net/2007/07/episode-62-martin-odersky-on-scala/) of functional programming are elaborated by Martin Odersky - First class and high-order **functions** and **immutability**. Another  key feature in functional programming is the **composition** - a style of development to build new things from small reusable elements. Functional code looks great only if functions clearly describe your problem. Usually, lines of code per function is only a single metric that reflects the [quality of the code](https://blog.usejournal.com/solving-embarrassingly-obvious-problems-in-erlang-e3f21a6203cc)\n\n\u003e If your functions have more than a few lines of code (a maximum of four to five lines per function is a good benchmark), you need to look more closely — chances are you have an opportunity to factor them into smaller, more tightly focused functions\n\nThis is because functions describe the solution to your problem. If your code contains many lines, then it is highly likely, that you are solving few problems without explicitly articulating them. And critical thinking is the process of software development - [Write small blocks of code](https://blog.ploeh.dk/2019/11/04/the-80-24-rule/).\n\nFunctional style programming can be achieved in any language, including Go. Golang's [structural type system](https://en.wikipedia.org/wiki/Structural_type_system) helps to reject invalid programs at compilation time. One of the challenge here is, that Go's structures, arrays, slices and maps embrace mutability rather than restricting it. Scala is a good example of the language that uses an imperative runtime but provides data structure implementations that inherently avoid mutation. This is a perfect approach to achieve immutability and performance through well-defined scopes. All-in-all, Go is a general purpose language with simple building blocks. This library uses these blocks to implement a functional style of development with the goal of simplicity in mind.\n\n\n## Getting started\n\nThe library requires **Go 1.18** or  later due to usage of [generics](https://go.dev/blog/intro-generics).\n\nThe latest version of the library is available at `main` branch. All development, including new features and bug fixes, take place on the `main` branch using forking and pull requests as described in contribution guidelines. The stable version is available via Golang modules. \n\n1. Use `go get` to retrieve the library and add it as a dependency to your application.\n\n```bash\ngo get -u github.com/fogfish/golem/{submodule}\n```\n\n2. Import required package in your code\n\n```go\nimport (\n  \"github.com/fogfish/golem/{submodule}\"\n)\n```\n\n## Examples and show cases \n* [Type classes](doc/typeclass.md)\n* [Higher-kinded polymorphism](doc/higher-kinded-polymorphism.md)\n* [A Guide To Higher-Kinded Type Classes with Golang](https://towardsdev.com/a-guide-to-higher-kinded-type-classes-with-golang-36dab6c9ecc4)\n* [Why higher-kinded polymorphism is vital functional abstraction and How to implement type classes with Golang](https://medium.com/@dmkolesnikov/why-higher-kinded-polymorphism-is-vital-functional-abstraction-and-how-to-implement-type-classes-b30ee0576dd5)\n* [Type combinators](doc/combinator.md) deliver powerful patterns for functional programming.\n* [A Guide To Pure Type Combinators in Golang or How to Stop Worrying and Love the Functional Programming](https://medium.com/@dmkolesnikov/a-guide-to-pure-type-combinators-in-golang-or-how-to-stop-worrying-and-love-the-functional-e14f7f8cf35c)\n* [Monoid](doc/monoid.md) for structural transformation.\n* [Abstract over Golang structure fields using optics](doc/abstract-over-struct-fields-using-optics.md)\n* [Heterogenous Sequence of Types](/hseq/)\n* [Golang Optics](/optics/)\n\n\n## How To Contribute\n\nThe library is [MIT](LICENSE) licensed and accepts contributions via GitHub pull requests:\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\nThe build and testing process requires [Go](https://golang.org) version 1.18 or later.\n\n**Build** and **run** in your development console.\n\n```bash\ngit clone https://github.com/fogfish/golem\ncd golem/{submodule}\ngo test ./...\n```\n\n## License\n\n[![See LICENSE](https://img.shields.io/github/license/fogfish/golem.svg?style=for-the-badge)](LICENSE)\n\n\u003c!--\n\nhttps://writings.stephenwolfram.com/2020/12/combinators-and-the-story-of-computation/\nhttps://files.wolframcdn.com/pub/www.wolframscience.com/nks/nks-ch12.pdf\nhttps://www.wolframscience.com/nks/\n\nhttps://cmc.gitbook.io/go-internals/chapter-ii-interfaces\nhttps://www.cockroachlabs.com/blog/how-we-built-a-vectorized-execution-engine/\nhttp://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=B3EBE6337709E0E494DB7074FC4D247A?doi=10.1.1.17.524\u0026rep=rep1\u0026type=pdf\nhttps://www.cs.cmu.edu/~ckingsf/bioinfo-lectures/skiplists.pdf\nhttps://github.com/avelino/awesome-go#networking\n\n\nResearch on the interface of Golang\nhttps://laptrinhx.com/research-on-the-interface-of-golang-4184713904/\n\n\nCategory Theory 10.1: Monads\nhttps://www.youtube.com/watch?v=gHiyzctYqZ0\u0026list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_\u0026index=21\u0026t=4s\n\nTypeScript on steroids\nhttps://dev.to/gcanti/getting-started-with-fp-ts-setoid-39f3\nhttps://dev.to/gcanti/functional-design-combinators-14pn\nhttps://dev.to/gcanti/getting-started-with-fp-ts-setoid-39f3\nhttps://dev.to/gcanti/functional-design-combinators-14pn\n\nScala Cats\nhttps://typelevel.org/cats/typeclasses.html\nhttps://typelevel.org/cats/typeclasses/monoid.html\nhttps://typelevel.org/cats/typeclasses/semigroup.html\n\nHTK\nhttps://github.com/ocamllabs/higher\nhttps://bow-swift.io/docs/fp-concepts/higher-kinded-types/\nhttps://github.com/gcanti/fp-ts/blob/master/src/Eq.ts\n\n\nhttps://go101.org/article/details.html\nhttps://github.com/emirpasic/gods\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogfish%2Fgolem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffogfish%2Fgolem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogfish%2Fgolem/lists"}