{"id":17145074,"url":"https://github.com/crufter/functional","last_synced_at":"2025-04-13T11:13:02.038Z","repository":{"id":62866952,"uuid":"560965333","full_name":"crufter/functional","owner":"crufter","description":"A functional \"standard\" library for Golang.","archived":false,"fork":false,"pushed_at":"2022-11-02T16:45:10.000Z","size":8,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T11:12:56.649Z","etag":null,"topics":[],"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/crufter.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":"2022-11-02T16:39:39.000Z","updated_at":"2022-11-17T17:43:27.000Z","dependencies_parsed_at":"2022-11-08T06:48:15.114Z","dependency_job_id":null,"html_url":"https://github.com/crufter/functional","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/crufter%2Ffunctional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crufter%2Ffunctional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crufter%2Ffunctional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crufter%2Ffunctional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crufter","download_url":"https://codeload.github.com/crufter/functional/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703198,"owners_count":21148118,"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":[],"created_at":"2024-10-14T21:04:23.864Z","updated_at":"2025-04-13T11:13:02.006Z","avatar_url":"https://github.com/crufter.png","language":"Go","readme":"# functional\n\nA functional \"standard\" library for Golang.\n\n## Why\n\n- To spark discussion and ideas\n- To make algorithmic/data oriented work with Go easier and faster\n- To push the edges of Go's type system (test driving generics)\n- For fun (putting the fun in functional)\n- Why not?\n\n8 years ago I wrote an [article](https://crufter.com/everyday-hassles-in-go) about the limitations of the typesystem of Go. It resonated with a lot of people so much that it even ended up on [Wikipedia](\u003chttps://en.wikipedia.org/wiki/Go_(programming_language)\u003e) as a source (under the criticism section - seems like I'm a professional hater!).\n\nSince the majority of the points in my post were about the lack of generics, it was about time I test drove the generic features.\n\nThis project is that test drive.\n\n## How\n\nCurrently this package is extremely heavily inspired by the Haskell standard library. To the point of stealing their comments and examples. Don't tell them. I hope their stuff is MIT :fingers-crossed:.\n\n## Examples\n\nFrom the obvious ones like Map\n\n```go\ndouble := func(i int) int {\n\treturn i * 2\n}\nv := list.Map(double, []int{1, 2, 3})\nfmt.Println(v)\n// prints 2, 4, 6\n```\n\nto more peculiar ones like\n\n```go\nlist.StripPrefix([]string{\"f\", \"o\", \"o\"}, []string{\"f\", \"o\", \"o\", \"b\", \"a\", \"r\"})\n// returns maybe.NewJust([]string{\"b\", \"a\", \"r\"})\n\nlist.StripPrefix([]string{\"f\", \"o\", \"o\"}, []string{\"b\", \"a\", \"r\", \"f\", \"o\", \"o\"})\n// returns maybe.NewNothing[[]string]()\n```\n\nor fairly crazy stuff like [Currying](https://en.wikipedia.org/wiki/Currying)\n\n```go\nadd := func(i, j int) int {\n\treturn i + j\n}\naddTo3 := function.Curry(add, 3)\naddTo3(5)\n// pints 8\n```\n\nto [tuples](https://en.wikipedia.org/wiki/Tuple)\n\n```go\n// Uncons decomposes a list into its head and tail.\n// Uncons[A any](xs []A) maybe.Maybe[tuple.Couple[A, []A]]\nm := list.Uncons([]int{1, 2, 3})\nif !m.IsJust() {\n    panic(\"uncons returned Nothing\")\n}\nt := m.Get()\nhead := t.E1()\ntail := t.E2()\nfmt.Printn(head, tail)\n// prints 1, []int{2, 3}\n```\n\nhave fun and don't blame me.\n\n## Status\n\nExtremely early.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrufter%2Ffunctional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrufter%2Ffunctional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrufter%2Ffunctional/lists"}