{"id":34954961,"url":"https://github.com/siy/pragmatica-lite","last_synced_at":"2026-01-05T09:11:20.043Z","repository":{"id":45992384,"uuid":"418053303","full_name":"siy/pragmatica-lite","owner":"siy","description":"Modern Functional Programming for Java 25","archived":false,"fork":false,"pushed_at":"2025-12-23T14:36:20.000Z","size":1463,"stargazers_count":41,"open_issues_count":8,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-24T01:54:07.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-17T07:24:51.000Z","updated_at":"2025-12-23T08:25:02.000Z","dependencies_parsed_at":"2024-12-25T12:27:37.985Z","dependency_job_id":"8ebc1cf5-e1d4-4047-be1f-c3aa41420c87","html_url":"https://github.com/siy/pragmatica-lite","commit_stats":null,"previous_names":["siy/pragmatica-lite"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/siy/pragmatica-lite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siy%2Fpragmatica-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siy%2Fpragmatica-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siy%2Fpragmatica-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siy%2Fpragmatica-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siy","download_url":"https://codeload.github.com/siy/pragmatica-lite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siy%2Fpragmatica-lite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28062336,"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","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"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":[],"created_at":"2025-12-26T22:00:05.324Z","updated_at":"2026-01-05T09:11:20.037Z","avatar_url":"https://github.com/siy.png","language":"Java","funding_links":["https://github.com/sponsors/siy"],"categories":["\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":[],"readme":"# Pragmatica Lite\n\n![License](https://img.shields.io/badge/license-Apache%202-blue.svg)\n![Java](https://img.shields.io/badge/Java-25-orange.svg)\n![Maven Central](https://img.shields.io/badge/Maven-0.9.7-blue.svg)\n\n## Modern Functional Programming for Java 25\n\nPragmatica Lite brings the power of functional programming to Java with zero-dependency monadic types that eliminate null pointer exceptions, unchecked exceptions, and callback hell. Built on Java 25's latest features including sealed interfaces and pattern matching.\n\n## Why Pragmatica Lite?\n\n**Without Pragmatica:**\n```java\n// Traditional Java - prone to NPE and unhandled exceptions\npublic User getUser(String id) throws UserNotFoundException, DatabaseException {\n    User user = database.findUser(id);  // Can throw exception\n    if (user == null) {                 // NPE risk\n        throw new UserNotFoundException(id);\n    }\n    return user;\n}\n```\n\n**With Pragmatica:**\n```java\n// Clean, safe, composable\npublic Result\u003cUser\u003e getUser(String id) {\n    return database.findUser(id)\n        .filter(user -\u003e user.isActive())\n        .map(this::enrichUserData)\n        .recover(DatabaseError.class, this::handleDatabaseError);\n}\n```\n\n## Core Features\n\n### Eliminate Null Pointer Exceptions\n```java\nOption\u003cString\u003e name = Option.of(user.getName())\n    .map(String::toUpperCase)\n    .filter(n -\u003e n.length() \u003e 2)\n    .orElse(\"Anonymous\");\n```\n\n### Safe Error Handling Without Exceptions\n```java\nResult\u003cInteger\u003e divide(int a, int b) {\n    return b == 0\n        ? Result.err(new MathError(\"Division by zero\"))\n        : Result.ok(a / b);\n}\n\n// Chain operations safely\nResult\u003cString\u003e result = divide(10, 2)\n    .map(x -\u003e x * 2)\n    .map(Object::toString)\n    .recover(MathError.class, err -\u003e \"Error: \" + err.message());\n```\n\n### Asynchronous Programming Made Simple\n```java\nPromise\u003cUserProfile\u003e getUserProfile(String userId) {\n    return fetchUser(userId)\n        .flatMap(user -\u003e fetchPreferences(user.id()).map(prefs -\u003e new UserProfile(user, prefs)))\n        .onSuccess(profile -\u003e cache.store(profile))\n        .onFailure(error -\u003e logger.error(\"Failed to load profile\", error));\n}\n```\n\n### Process Collections Safely\n```java\nList\u003cResult\u003cUser\u003e\u003e userResults = userIds.stream()\n    .map(this::fetchUser)\n    .toList();\n\n// Collect all successes, fail if any operation failed\nResult\u003cList\u003cUser\u003e\u003e allUsers = Result.allOf(userResults);\n\n// Or collect only successful operations\nList\u003cUser\u003e validUsers = Result.collectSuccesses(userResults);\n```\n\n## Modern Java 25 Features\n\nPragmatica Lite leverages cutting-edge Java 25 features:\n\n- **Sealed Interfaces**: Type-safe Result and Option hierarchies\n- **Pattern Matching**: Elegant switch expressions for monadic types\n- **Records**: Immutable data structures throughout\n\n### Maven Configuration\n\nPragmatica Lite is available on Maven Central. Simply add the dependency to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.pragmatica-lite\u003c/groupId\u003e\n    \u003cartifactId\u003ecore\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.7\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nFor Gradle users:\n\n```gradle\nimplementation 'org.pragmatica-lite:core:0.9.7'\n```\n\n### Your First Pragmatica Application\n\n```java\nimport org.pragmatica.lang.*;\n\npublic class Example {\n    // Safe division that never throws\n    public static Result\u003cDouble\u003e safeDivide(double a, double b) {\n        return b == 0.0\n            ? MathError.divisionByZero().result()\n            : Result.ok(a / b);\n    }\n\n    // Chaining operations\n    static void main(String[] args) {\n        safeDivide(10.0, 2.0)\n            .map(result -\u003e result * 2)  // Transform success value\n            .fold(\n                error -\u003e \"Error: \" + error.message(),\n                success -\u003e \"Result: \" + success\n            );\n    }\n}\n```\n\n## API Overview\n\n### Result\u0026lt;T\u0026gt; - Railway-Oriented Programming\nHandle success and failure without exceptions:\n\n```java\nResult\u003cString\u003e result = processData()\n    .map(String::trim)\n    .filter(s -\u003e !s.isEmpty())\n    .recover(ValidationError.class, err -\u003e \"default\");\n```\n\n### Option\u0026lt;T\u0026gt; - Null Safety\nEliminate null pointer exceptions:\n\n```java\nOption\u003cUser\u003e user = findUser(id)\n    .filter(User::isActive)\n    .map(User::getProfile);\n```\n\n### Promise\u0026lt;T\u0026gt; - Async Operations\nComposable asynchronous programming:\n\n```java\nPromise\u003cString\u003e response = httpClient.get(url)\n    .map(Response::body)\n    .timeout(Duration.ofSeconds(5))\n    .onFailure(err -\u003e logger.error(\"Request failed\", err));\n```\n\n## Design Principles\n\n- **Zero Dependencies**: No external libraries required\n- **Type Safety**: Leverage Java's type system for correctness\n- **Performance**: Minimal overhead, allocation-free operations\n- **Composability**: Chain operations naturally\n- **Modern Java**: Built for Java 25 and beyond\n\n## Examples and Documentation\n\nExplore comprehensive examples in the [examples](examples) directory:\n- Asynchronous data processing with Promise\n- Error handling patterns with Result\n- Null-safe operations with Option\n- Real-world application patterns\n\n## Module Structure\n\n| Module | Description |\n|--------|-------------|\n| **core** | Core monadic types: Result, Option, Promise |\n| **examples** | Sample applications and usage patterns |\n\n### Integration Modules\n\n| Category | Module | Description | Docs |\n|----------|--------|-------------|------|\n| **Config** | [toml](integrations/config/toml) | Zero-dependency TOML parser | [README](integrations/config/toml/README.md) |\n| **Consensus** | [consensus](integrations/consensus) | Rabia consensus protocol (CFT) | [README](integrations/consensus/README.md) |\n| **Database** | [jdbc](integrations/db/jdbc) | Promise-based JDBC with HikariCP | [README](integrations/db/jdbc/README.md) |\n| | [jpa](integrations/db/jpa) | JPA/Hibernate integration | [README](integrations/db/jpa/README.md) |\n| | [r2dbc](integrations/db/r2dbc) | Reactive database access | [README](integrations/db/r2dbc/README.md) |\n| | [jooq](integrations/db/jooq) | Promise-based JOOQ with JDBC | — |\n| | [jooq-r2dbc](integrations/db/jooq-r2dbc) | Promise-based JOOQ with R2DBC | [README](integrations/db/jooq-r2dbc/README.md) |\n| **Distributed** | [dht](integrations/dht) | Distributed Hash Table | [README](integrations/dht/README.md) |\n| **JSON** | [jackson](integrations/json/jackson) | Jackson 3.0 serialization | [README](integrations/json/jackson/README.md) |\n| **Messaging** | [messaging](integrations/messaging) | Message queue abstractions | [README](integrations/messaging/README.md) |\n| **Metrics** | [micrometer](integrations/metrics/micrometer) | Micrometer observability | [README](integrations/metrics/micrometer/README.md) |\n| **Network** | [http-client](integrations/net/http-client) | Promise-based HTTP client | [README](integrations/net/http-client/README.md) |\n| | [tcp](integrations/net/tcp) | TCP networking utilities | [README](integrations/net/tcp/README.md) |\n| | [dns](integrations/net/dns) | DNS client | [README](integrations/net/dns/README.md) |\n| **Serialization** | [serialization](integrations/serialization) | Binary serialization (Fury, Kryo) | [README](integrations/serialization/README.md) |\n\n## Integrations\n\n### Jackson JSON (3.0.0)\n\nSerialize and deserialize Result, Option, and Promise types:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.pragmatica-lite\u003c/groupId\u003e\n    \u003cartifactId\u003ejackson\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.7\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```java\nvar mapper = JsonMapper.jsonMapper()\n    .withPragmaticaTypes()\n    .build();\n\n// Result\u003cT\u003e serialization\nResult\u003cUser\u003e result = fetchUser(id);\nmapper.writeAsString(result)  // Result\u003cString\u003e\n    .onSuccess(json -\u003e sendResponse(json));\n\n// Type-safe deserialization\nmapper.readString(json, new TypeToken\u003cList\u003cUser\u003e\u003e() {})\n    .onSuccess(users -\u003e processUsers(users));\n```\n\n### JPA Database Integration\n\nPromise-based JPA operations with typed errors:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.pragmatica-lite\u003c/groupId\u003e\n    \u003cartifactId\u003ejpa\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.7\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```java\nvar ops = JpaOperations.jpaOperations(entityManager);\n\n// Transactional operations\nPromise\u003cUser\u003e result = Transactional.withTransaction(\n    entityManager,\n    JpaError::fromException,\n    tx -\u003e ops.persist(newUser)\n        .flatMap(saved -\u003e ops.flush().map(_ -\u003e saved))\n);\n\n// Typed errors: EntityNotFound, OptimisticLock, DatabaseFailure, etc.\nresult.onFailure(error -\u003e switch (error) {\n    case JpaError.EntityNotFound _ -\u003e handleNotFound();\n    case JpaError.OptimisticLock lock -\u003e handleConflict(lock.entityType());\n    case JpaError.DatabaseFailure db -\u003e handleDatabaseError(db.cause());\n    default -\u003e handleUnexpected(error);\n});\n```\n\n### Micrometer Metrics\n\nMonitor Result, Option, and Promise operations:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.pragmatica-lite\u003c/groupId\u003e\n    \u003cartifactId\u003emicrometer\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.7\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```java\n// Wrap operations with metrics\nvar wrappedOperation = ResultMetrics.timed(\n    registry,\n    \"user.fetch\",\n    Tags.of(\"service\", \"user-service\"),\n    () -\u003e fetchUser(userId)\n);\n\n// Automatic success/failure tracking\nPromise\u003cData\u003e monitored = PromiseMetrics.counted(\n    registry,\n    \"api.call\",\n    Tags.of(\"endpoint\", \"/users\"),\n    apiClient.fetchData()\n);\n```\n\n## Contributing\n\nWe welcome contributions! Please feel free to submit pull requests, report issues, or suggest improvements.\n\n### Development Requirements\n- Java 25 or higher\n- Maven 3.9+\n\n## Support\n\nIf you find this useful, consider [sponsoring](https://github.com/sponsors/siy).\n\n## License\n\nLicensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiy%2Fpragmatica-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiy%2Fpragmatica-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiy%2Fpragmatica-lite/lists"}