{"id":40970663,"url":"https://github.com/coenttb/swift-logic-operators","last_synced_at":"2026-01-22T06:43:07.482Z","repository":{"id":249309952,"uuid":"831052210","full_name":"coenttb/swift-logic-operators","owner":"coenttb","description":"A Swift package with logical operators for optional Boolean values and Predicates.","archived":false,"fork":false,"pushed_at":"2025-10-30T21:36:54.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T23:28:45.349Z","etag":null,"topics":["logic","optional-logic","predicate-logic","swift"],"latest_commit_sha":null,"homepage":"https://coenttb.com","language":"Swift","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/coenttb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["coenttb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2024-07-19T14:47:53.000Z","updated_at":"2025-10-30T21:36:58.000Z","dependencies_parsed_at":"2024-12-19T12:28:43.287Z","dependency_job_id":"1bcdea05-3486-4531-ade1-ac0dd3e8c536","html_url":"https://github.com/coenttb/swift-logic-operators","commit_stats":null,"previous_names":["coenttb/swift-logic-operators"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/coenttb/swift-logic-operators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-logic-operators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-logic-operators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-logic-operators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-logic-operators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coenttb","download_url":"https://codeload.github.com/coenttb/swift-logic-operators/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-logic-operators/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["logic","optional-logic","predicate-logic","swift"],"created_at":"2026-01-22T06:43:07.389Z","updated_at":"2026-01-22T06:43:07.474Z","avatar_url":"https://github.com/coenttb.png","language":"Swift","funding_links":["https://github.com/sponsors/coenttb"],"categories":[],"sub_categories":[],"readme":"# Swift Logic Operators\n\n[![CI](https://github.com/coenttb/swift-logic-operators/workflows/CI/badge.svg)](https://github.com/coenttb/swift-logic-operators/actions/workflows/ci.yml)\n![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)\n\nLogical operators for optional Boolean values and predicates in Swift.\n\n## Overview\n\nSwift Logic Operators extends Swift's logical operators to work with optional Boolean values and predicate functions (closures returning `Bool`). It provides type-safe implementations of common logical operations that handle `nil` values gracefully and compose predicates functionally.\n\n## Features\n\n- **Optional Boolean Operators**: NOT (`!`), AND (`\u0026\u0026`), OR (`||`), XOR (`^`), NAND (`!\u0026\u0026`), NOR (`!||`), XNOR (`!^`)\n- **Predicate Composition**: Combine and transform `(A) -\u003e Bool` closures with logical operators\n- **Nil-Safe**: All optional operators return `nil` when any operand is `nil`\n- **Type-Safe**: Compile-time guarantees for logical operations\n- **Error Handling**: Support for throwing closures with `rethrows`\n\n## Installation\n\nAdd the package to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-logic-operators.git\", from: \"0.1.0\")\n]\n```\n\nThen add the product to your target:\n\n```swift\ntargets: [\n    .target(\n        name: \"YourTarget\",\n        dependencies: [\n            .product(name: \"LogicOperators\", package: \"swift-logic-operators\")\n        ]\n    )\n]\n```\n\n## Quick Start\n\n```swift\nimport LogicOperators\n\n// Optional Boolean operations\nlet a: Bool? = true\nlet b: Bool? = nil\nlet result = a \u0026\u0026 b  // nil\n\n// Predicate composition\nlet isEven: (Int) -\u003e Bool = { $0 % 2 == 0 }\nlet isPositive: (Int) -\u003e Bool = { $0 \u003e 0 }\nlet isEvenAndPositive = isEven \u0026\u0026 isPositive\n\nisEvenAndPositive(4)  // true\nisEvenAndPositive(-4) // false\n```\n\n## Usage\n\n### Optional Boolean Operators\n\nAll optional Boolean operators propagate `nil` values:\n\n```swift\nlet t: Bool? = true\nlet f: Bool? = false\nlet n: Bool? = nil\n\n// NOT\n!t  // false\n!f  // true\n!n  // nil\n\n// AND\nt \u0026\u0026 f  // false\nt \u0026\u0026 n  // nil\nf \u0026\u0026 n  // nil\n\n// OR\nt || f  // true\nt || n  // true\nf || n  // nil\n\n// XOR\nt ^ f  // true\nt ^ n  // nil\nf ^ f  // false\n\n// NAND\n(t !\u0026\u0026 f)  // true\n(t !\u0026\u0026 t)  // false\n\n// NOR\n(t !|| f)  // false\n(f !|| f)  // true\n\n// XNOR\n(t !^ f)  // false\n(t !^ t)  // true\n```\n\n### Predicate Composition\n\nCombine Boolean predicates using logical operators:\n\n```swift\nlet isEven: (Int) -\u003e Bool = { $0 % 2 == 0 }\nlet isPositive: (Int) -\u003e Bool = { $0 \u003e 0 }\n\n// AND\nlet isEvenAndPositive = isEven \u0026\u0026 isPositive\nisEvenAndPositive(4)  // true\nisEvenAndPositive(-4) // false\n\n// OR\nlet isNegative: (Int) -\u003e Bool = { $0 \u003c 0 }\nlet isEvenOrNegative = isEven || isNegative\nisEvenOrNegative(3)  // false\nisEvenOrNegative(-3) // true\n\n// NOT\nlet isOdd = !isEven\nisOdd(5)  // true\nisOdd(4)  // false\n\n// XOR\nlet isEvenXorPositive = isEven ^ isPositive\nisEvenXorPositive(4)  // false (both true)\nisEvenXorPositive(-4) // true  (even but not positive)\nisEvenXorPositive(3)  // true  (positive but not even)\nisEvenXorPositive(-3) // false (neither)\n\n// Equality\nlet same = isEven == isPositive\nsame(4)  // true (both predicates return true for 4)\nsame(-4) // false (isEven true, isPositive false)\nsame(3)  // false (isEven false, isPositive true)\nsame(-3) // true (both predicates return false for -3)\n\n// Inequality\nlet different = isEven != isPositive\ndifferent(4)  // false (both predicates return true)\ndifferent(-4) // true (different results)\ndifferent(3)  // true (different results)\ndifferent(-3) // false (both predicates return false)\n```\n\n## Related Packages\n\n### Used By\n\n- [coenttb-ui](https://github.com/coenttb/coenttb-ui): A Swift package with UI components for coenttb applications.\n\n## License\n\nThis project is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-logic-operators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoenttb%2Fswift-logic-operators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-logic-operators/lists"}