{"id":18791878,"url":"https://github.com/saksmt/f4py","last_synced_at":"2025-07-04T15:37:14.029Z","repository":{"id":57428038,"uuid":"53150431","full_name":"saksmt/f4py","owner":"saksmt","description":"Algebraic types, like Maybe (Optional), Either and Try for python3","archived":false,"fork":false,"pushed_at":"2016-03-10T08:01:22.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-06-22T06:37:24.958Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saksmt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-04T16:49:04.000Z","updated_at":"2016-03-04T16:50:20.000Z","dependencies_parsed_at":"2022-09-09T03:00:10.928Z","dependency_job_id":null,"html_url":"https://github.com/saksmt/f4py","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/saksmt/f4py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Ff4py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Ff4py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Ff4py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Ff4py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saksmt","download_url":"https://codeload.github.com/saksmt/f4py/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Ff4py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263568093,"owners_count":23481613,"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-11-07T21:17:13.959Z","updated_at":"2025-07-04T15:37:13.995Z","avatar_url":"https://github.com/saksmt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# f4py\n\nFunctional (algebraic) data types for python\n\n## Classes\n\n - `f4py.Maybe`\n - `f4py.Either`\n - `f4py.Try`\n - `f4py.Monad`\n - `f4py.exception.NotPresentException`\n - `f4py.exception.CompositeException`\n\n## Usage\n\n```python\n\nfrom f4py import \\\n    maybe,\\\n    just,\\\n    nothing,\\\n    either,\\\n    left,\\\n    right,\\\n    attempt,\\\n    success,\\\n    failure\n\nmy_value = maybe(receive())\nnonable_value = maybe(get_from_somewhere())\nresult = nonable_value\\\n    .map(extract_something)\\\n    .filter(out_something)\\\n    .if_absent(my_value)\\\n    .flat_compute_if_absent(my_maybe_producer)\\\n    .peek(print)\n    .or_else(5)\n\ncomputed_result = attempt(do_some_work)\\\n    .map(convert_to_something)\\\n    .fallback(do_some_other_work)\\\n    .on_error(print)\\ # non terminable\n    .handle_error(error_handler)\\\n    .or_else(result)\n\none_or_other = either(get_tuple())\\\n    .map(side_independent_converter)\\\n    .bimap(left_mapper, right_mapper)\n\nany_result = one_or_other.unpack()\n\nif one_or_other.is_left():\n    print('It was left!')\nelse:\n    print('It was right!')\n\nr_value = one_or_other.get_right().if_absent(just(5))\nl_value = one_or_other.get_left().or_else_compute(lambda: 10)\n```\n\nThat's it. For more see [documentation](./doc) and use `Ctrl` + `Space` :)\n\n## Roadmap\n\nMaybe implement streams\n\n## License\n\nLibrary is licensed under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaksmt%2Ff4py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaksmt%2Ff4py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaksmt%2Ff4py/lists"}