{"id":26057420,"url":"https://github.com/aabbtree77/expression-problem","last_synced_at":"2025-03-08T11:15:25.612Z","repository":{"id":279312727,"uuid":"938400775","full_name":"aabbtree77/expression-problem","owner":"aabbtree77","description":"The expression problem solved by DeepSeek in Go, Rust, and Haskell.","archived":false,"fork":false,"pushed_at":"2025-02-24T23:06:49.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T23:30:40.339Z","etag":null,"topics":["abstractions","barendregt-cube","deepseek-v3","expression-problem","lambda-cube","language-design","open-interface","type-embedding"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/aabbtree77.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-24T22:34:02.000Z","updated_at":"2025-02-24T23:06:53.000Z","dependencies_parsed_at":"2025-02-24T23:40:44.361Z","dependency_job_id":null,"html_url":"https://github.com/aabbtree77/expression-problem","commit_stats":null,"previous_names":["aabbtree77/expression-problem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fexpression-problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fexpression-problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fexpression-problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fexpression-problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aabbtree77","download_url":"https://codeload.github.com/aabbtree77/expression-problem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242539058,"owners_count":20145892,"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":["abstractions","barendregt-cube","deepseek-v3","expression-problem","lambda-cube","language-design","open-interface","type-embedding"],"created_at":"2025-03-08T11:15:24.985Z","updated_at":"2025-03-08T11:15:25.582Z","avatar_url":"https://github.com/aabbtree77.png","language":"Rust","readme":"\u003e \"All of the things I once held, precious just don't  \n\u003e Mean anything anymore...\"\n\u003e\n\u003e — *Kim Wilde, 1988*\n\n## Introduction\n\nThe expression problem: [1](https://en.wikipedia.org/wiki/Expression_problem), [2](https://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/) is the challenge of adding new data types that satisfy given operations and adding new operations on those types without modifying existing code, while maintaining type safety.\n\nIt is a solid way to assess programming languages.\n\n## Go, Rust, and Haskell\n\n```console\ngo run add_type.go\nrustc add_operation.rs -o output \u0026\u0026 ./output\nrunghc add_type_and_operation.hs\n```\n\n- add_type.go: `interface`. Easy to add a new type.\n\n- add_operation.rs: `enum`. Easy to add a new operation. Exhaustive checks.\n\n- add_operation.go: **type embedding** (wrapping, composition, \"has a\", not \"is a\"). Note that in Go, one cannot simply add methods to existing types from other packages.\n\n- add_type.rs: `\u003cdyn Trait\u003e` instead of `enum`, but this relies on dynamic dispatch, and we lose exhaustive checks. \n\n- add_type_static.rs. When asked to remove dynamic dispatch, DeepSeek hallucinates with `PhantomData` and weird \"type erasure\" codes which produce compiler errors. When hinted to use generics or macros, it does the job. This particular code manages to remove dynamic dispatch, but is limited as it does not lead to heterogeneous containers.\n\n- add_type_macro.rs. One of those rare motivations for a macro. This is still fairly limited as the macro must belong to the same crate with all the types (the orphan rule blocks implementing foreign traits for foreign types). This will typically demand forking the whole crate.\n\n- add_type_and_operation.hs. Haskell comes and wipes the floor with 'em all. Open types, open operations (type classes), the ability to iterate over a heterogeneous list (existential types), type class resolution at compile time. \n \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabbtree77%2Fexpression-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabbtree77%2Fexpression-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabbtree77%2Fexpression-problem/lists"}