{"id":20646943,"url":"https://github.com/bkase/swift-di-explorations","last_synced_at":"2025-10-24T01:47:44.205Z","repository":{"id":143405343,"uuid":"92909903","full_name":"bkase/swift-di-explorations","owner":"bkase","description":"Functional DI explorations in Swift","archived":false,"fork":false,"pushed_at":"2017-10-25T02:44:33.000Z","size":745,"stargazers_count":28,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T02:53:07.090Z","etag":null,"topics":["dependency-injection","di","functional","swift","typesafe"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/bkase.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-31T05:57:31.000Z","updated_at":"2022-04-22T17:03:52.000Z","dependencies_parsed_at":"2023-05-24T13:15:37.054Z","dependency_job_id":null,"html_url":"https://github.com/bkase/swift-di-explorations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bkase/swift-di-explorations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkase%2Fswift-di-explorations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkase%2Fswift-di-explorations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkase%2Fswift-di-explorations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkase%2Fswift-di-explorations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkase","download_url":"https://codeload.github.com/bkase/swift-di-explorations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkase%2Fswift-di-explorations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280723933,"owners_count":26380108,"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-10-23T02:00:06.710Z","response_time":142,"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":["dependency-injection","di","functional","swift","typesafe"],"created_at":"2024-11-16T16:28:25.160Z","updated_at":"2025-10-24T01:47:44.141Z","avatar_url":"https://github.com/bkase.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Functional DI Solutions in Swift\n\nOur code has dependencies. We would like to not directly invoke code that uses side-effecting singleton-esque services because our code becomes harder to reason about, harder to test, etc. It would be nice to decouple the effects.\n\nDependency injection is about decoupling your code from your effects. In traditional OO languages, it's tough to get a compile-time-checked type-safe DI solution working, but Swift is functional(ish).\n\nThis repository explores the \"functional\" solutions to DI that are used in other functional languages (Scala, Haskell, etc)\n\n## Understanding the solutions\n\nIn this repo, every implemenation must declare a dependency on some datastore that has the capability to get a string key-value pair given a string key, and set arbitrary key-value pairs given a key and a value.\n\nIn all cases, we define a simple program that sets a key-value pair, and then gets that key and uses it to say \"hello\".\n\nThe programs are declared here in literate Swift:\n\n* [Cake Pattern](Sources/di-playground/Cake.swift)\n\n[![Cake pattern](img/cake.png)](Sources/di-playground/Cake.swift)\n\n* [Reader Monad](Sources/di-playground/Reader.swift)\n\n[![Reader Monad](img/reader.png)](Sources/di-playground/Reader.swift)\n\n* [Free Monad](Sources/di-playground/Free.swift)\n\n[![Free Monad](img/free.png)](Sources/di-playground/Free.swift)\n\nThe programs are then all evaluated in this\n\n* [Test file](Tests/di-playgroundTests/di_playgroundTests.swift)\n\n[![Test file](img/test.png)](Tests/di-playgroundTests/di_playgroundTests.swift)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkase%2Fswift-di-explorations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkase%2Fswift-di-explorations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkase%2Fswift-di-explorations/lists"}