{"id":19708201,"url":"https://github.com/toptobes/haskell-in-c99-kinda","last_synced_at":"2026-05-10T20:37:54.412Z","repository":{"id":191737868,"uuid":"685285540","full_name":"toptobes/haskell-in-c99-kinda","owner":"toptobes","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-31T22:37:32.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-10T13:15:25.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/toptobes.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":"2023-08-30T22:44:18.000Z","updated_at":"2023-09-08T20:12:32.000Z","dependencies_parsed_at":"2024-11-11T21:42:55.493Z","dependency_job_id":"0217c253-8e55-4a05-8374-3f7ca6aadc3c","html_url":"https://github.com/toptobes/haskell-in-c99-kinda","commit_stats":null,"previous_names":["toptobes/haskell-in-gnu99","toptobes/haskell-in-c99"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptobes%2Fhaskell-in-c99-kinda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptobes%2Fhaskell-in-c99-kinda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptobes%2Fhaskell-in-c99-kinda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptobes%2Fhaskell-in-c99-kinda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toptobes","download_url":"https://codeload.github.com/toptobes/haskell-in-c99-kinda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241024483,"owners_count":19896237,"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":[],"created_at":"2024-11-11T21:42:42.079Z","updated_at":"2026-05-10T20:37:49.201Z","avatar_url":"https://github.com/toptobes.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Why am I doing this in C, you ask?\n\n### because I have nothing better to do with my life\n\n```c\n/* using the double preprocessing version */\n\nCreateTypeClass(Functor unconstrained)\nCreateTypeClass(Applicative constrainedBy Functor)\nCreateTypeClass(Monad constrainedBy Applicative)\n\nCreateData(Maybe containing void* value; int isNothing constrainedBy Monad)\n\nMaybe Just(int *p) \n{\n    return (Maybe) { .isNothing = 0, .value = p };\n}\n\nvoid* fromJust(Maybe m) \n{\n    return m.value;\n}\n\nMaybe fmapMaybe(Maybe m, void* (**fn)(void*, void*)) \n{\n    return m.isNothing ? m : Just $ Call $ fn, fromJust (m) end2\n}\n\n// _Generic's not really extensible ik, might break my rules slightly and add a pre-preprocessor\n// script to collect typeclass method implementations and aggregate them in the _Generics\n#define fmap(self, fn) _Generic(self, Maybe: fmapMaybe(self, fn))\n\n// Using a deferred definition here so fmap can be used with $ as well\n// Again could add automation script to ./run for this though that's kinda cheating\n#define DEFERRED_FMAP #define fmap(self, fn) _Generic(self, Maybe: fmapMaybe(self, fn))\nDEFERRED_FMAP\n\nint* add(const int amount, const int *a) \n{\n    return Allocated (*a + amount)\n}\n\nint main(int argc)\n{\n    return deref(int) fromJust $ fmap $ Just (\u0026argc), λ (add, 3) end2\n}\n```\n\nThere's two slightly different (non-source-compatible) versions of the interface:\n\n1. Use `./run` which defines `DOUBLEPP` and runs the C preprocessor twice,\n   enabling additional \"smoothing out\" of the API.\n2. Run it normally w/ cmake or whatever, which also works, but provides a\n   slightly rougher/more manual interface.\n\nThe preprocessor auto-generates functions to cast to base types in a safe manner.\nIf you're using mode #1, the functions will look like `Maybe2Monad` or\n`Maybe2Functor`, whereas if you use mode #2, they'll look like `Maybe2MonadN`\nwhere `N` is some number (to prevent name clashing in the event of multiple\ntype constraints).\n\nI'll finish this README later, I swear\n\nTODO: more typesafety and stuff\n\n*please, gods of C, don't come after me for this abomination*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoptobes%2Fhaskell-in-c99-kinda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoptobes%2Fhaskell-in-c99-kinda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoptobes%2Fhaskell-in-c99-kinda/lists"}