{"id":13307261,"url":"https://github.com/imfi-jz/haxe-functional","last_synced_at":"2025-03-10T14:32:45.130Z","repository":{"id":159159905,"uuid":"628369471","full_name":"imfi-jz/haxe-functional","owner":"imfi-jz","description":"Tools for writing Haxe code in the functional programming paradigm.","archived":false,"fork":false,"pushed_at":"2023-04-15T19:53:26.000Z","size":42,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-04-30T10:24:50.933Z","etag":null,"topics":["functional-programming","haxe","library"],"latest_commit_sha":null,"homepage":"https://discord.gg/2KedGjpQMR","language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imfi-jz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-04-15T18:23:58.000Z","updated_at":"2023-04-21T19:00:09.000Z","dependencies_parsed_at":"2023-05-01T14:49:06.563Z","dependency_job_id":null,"html_url":"https://github.com/imfi-jz/haxe-functional","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imfi-jz%2Fhaxe-functional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imfi-jz%2Fhaxe-functional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imfi-jz%2Fhaxe-functional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imfi-jz%2Fhaxe-functional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imfi-jz","download_url":"https://codeload.github.com/imfi-jz/haxe-functional/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242868629,"owners_count":20198519,"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":["functional-programming","haxe","library"],"created_at":"2024-07-29T18:00:15.641Z","updated_at":"2025-03-10T14:32:45.102Z","avatar_url":"https://github.com/imfi-jz.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Haxe Functional\n'Haxe Functional' (work in progress name) is a small library with a set of functions that help and extend the capabilities of writing [Haxe](https://haxe.org/) code in the functional programming paradigm. It provides functions for common functional collection operations like `filter`, `reduce`, `map` and more, and works on any collection (`Iterable`, `Array`, etc.) or map.\n\n## Usage\nClone the repository or download it as a zip and use the source code (under /src) as a library source in your project's hxml file (see section Disclaimer).\n\nThe functions can be used on a collection by assigning the collection to a variable of type `Multitude\u003cT\u003e` like so:\n```haxe\nfinal functionalArray:Multitude\u003cInt\u003e = [1, 2, 3];\nfinal twosOnly = functionalArray.filter((num) -\u003e num == 2);\n\nfinal functionalArray2:Multitude\u003cInt\u003e = 0...10;\nfinal oddsOnly = functionalArray2.reject((num) -\u003e num % 2 == 0);\n```\nThe `Multitude` type will respect the collection's order and provides functions to convert it back to `Array` or get its `Iterator` or `KeyValueIterator`.\n\nThe library also works on `Maps` (key value pairs) by assigning a map to a variable of type `Pairs\u003cK, V\u003e`, like so:\n```haxe\nfinal functionalMap:Pairs\u003cString, String\u003e = [\"M\" =\u003e \"Monday\", \"T\" =\u003e \"Tuesday\"];\nfinal mondaysOnly = functionalMap.filter((key, value) -\u003e key == \"M\");\n```\n\nHere is a list of all functions that available to functional collections (Multitude and Pairs):\n- `each` - executes a function for each item in the collection.\n- `filter` - retain only the items that meet a condition.\n- `find` - returns the first item that meets a condition.\n- `reject` - removes all items that meet a condition.\n- `map` - transforms each item in the collection to a given type.\n- `reduce` - reduces the collection to a single value.\n- `first` - returns the first item in the collection.\n- `any` - returns whether any item is present in the collection.\n\nFunction currying is also possible via the `abstract` `Curry` type. I forgot how exaclty this works (it's been a while since writing this code lol).\n\n## Compilation\nThis library was written for Haxe version 4. It should work with all compilation targets (with possibly a few exceptions).\n\nThe library can be compiled with a few different options.\n\nBy default all functional functions are inlined, resulting in potentially much less stack frames at runtime. This can be disabled with the following flag:\n```hxml\n-D no_functional_inline\n```\n\nTo increase performance, operations like filter, map, etc. can be executed on the instance itself instead of returning a new collection each time. This is agains the concept of functional programming and should only be used if you are 100% sure the side effects of mutating your collections do not matter. To enable direct mutation on your collections (`Multitude` and `Pairs`) add the following flag:\n```hxml\n-D functional_mutable\n```\n\n## Disclaimer\nI am providing this library as is, and am currently not making it an actual haxelib, as I am not 100% sure if every functional concept is implemented correctly. However, I still think this may be a useful tool to some.\n\nMost of the functions are to some degree documented.\n\nDo not expect regular updates for this library. If you decide to use this library I will try to provide support if you have questions. Suggestions are also welcome.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimfi-jz%2Fhaxe-functional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimfi-jz%2Fhaxe-functional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimfi-jz%2Fhaxe-functional/lists"}