{"id":37028057,"url":"https://github.com/kyle-silver/result-type-jvm","last_synced_at":"2026-01-14T03:20:49.014Z","repository":{"id":39714337,"uuid":"443451745","full_name":"kyle-silver/result-type-jvm","owner":"kyle-silver","description":"An ergonomic, Rust-inspired result type for JVM languages","archived":false,"fork":false,"pushed_at":"2022-07-03T19:54:08.000Z","size":174,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T20:52:37.446Z","etag":null,"topics":["algebraic-data-types","error-handling","java"],"latest_commit_sha":null,"homepage":"https://kyle-silver.github.io/result-type-jvm/dev/kylesilver/result/Result.html","language":"Java","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/kyle-silver.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-01-01T01:26:48.000Z","updated_at":"2023-02-09T01:58:48.000Z","dependencies_parsed_at":"2022-07-31T23:00:04.308Z","dependency_job_id":null,"html_url":"https://github.com/kyle-silver/result-type-jvm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kyle-silver/result-type-jvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyle-silver%2Fresult-type-jvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyle-silver%2Fresult-type-jvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyle-silver%2Fresult-type-jvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyle-silver%2Fresult-type-jvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyle-silver","download_url":"https://codeload.github.com/kyle-silver/result-type-jvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyle-silver%2Fresult-type-jvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","error-handling","java"],"created_at":"2026-01-14T03:20:48.282Z","updated_at":"2026-01-14T03:20:49.004Z","avatar_url":"https://github.com/kyle-silver.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Result Type for the Rest of Us\n\nThis package contains a small, composable Result type heavily inspired by Rust. It provides ergonomic and robust error handling and leverages Java's type system to make uncaught runtime exceptions a thing of the past.\n\n## Installation\n\nThis package can be found on [Maven Central](https://search.maven.org/artifact/dev.kylesilver/result-type-jvm). For POM files, add the following:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003edev.kylesilver\u003c/groupId\u003e\n  \u003cartifactId\u003eresult-type-jvm\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nFor Gradle projects, use:\n\n```groovy\nimplementation 'dev.kylesilver:result-type-jvm:0.1.2'\n```\n\n\n## Usage\n\nA `Result` type indicates that a value is either a success `Ok` or an error `Err`. Before accessing the value inside, you must inspect the `Result` to determine which of the two possible outcomes have occurred.\n\nInstead of throwing an exception, you can return an error value.\n\n```java\n// indicates the value was successful\nResult\u003cInteger, String\u003e ok = Result.ok(1);\n\n// indicates there was an error\nResult\u003cInteger, String\u003e err = Result.err(\"something went wrong!\");\n```\n\nIf you want to get the value out and throw an exception if there's an error, you can do so with `unwrap()`\n\n```java\nint value = result.unwrap();\n```\n\nYou can also substitute a default value in the event of an error\n\n```java\nint value = result.err().orElse(0);\n```\n\nAnd you can also apply stream-style maps which are only applied to the value if it is `Ok`\n\n```java\n// the map is applied to Ok values\nResult\u003cInteger, String\u003e result1 = Result.ok(5);\nString result = result1.map(x -\u003e Integer.toString(x)).unwrap();\n\n// but not to errors\nResult\u003cInteger, String\u003e result2 = Result.err(\"whoops!\");\nresult2.map(x -\u003e Integer.toString(x)).isErr(); // true\n```\n\nYou can use `match` to apply more complex manipulations to the result of an operation.\n\n```java\nResult\u003cInteger, String\u003e result = Result.ok(5);\nint computed = result.match(\n    ok -\u003e ok + 1,\n    err -\u003e {\n        log.warn(\"there was an error!\");\n        return 0;\n    }\n);\n```\n\nThere's a lot more that you can do with Result types, check out the [docs](https://kyle-silver.github.io/result-type-jvm/dev/kylesilver/result/Result.html) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyle-silver%2Fresult-type-jvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyle-silver%2Fresult-type-jvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyle-silver%2Fresult-type-jvm/lists"}