{"id":16336479,"url":"https://github.com/justinwoo/purescript-kishimen","last_synced_at":"2025-10-12T16:31:50.345Z","repository":{"id":58237378,"uuid":"171374956","full_name":"justinwoo/purescript-kishimen","owner":"justinwoo","description":"Sum types with Generics-Rep instances to Variant for free!","archived":false,"fork":false,"pushed_at":"2021-12-15T13:00:26.000Z","size":9,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-18T11:27:59.983Z","etag":null,"topics":["purescript"],"latest_commit_sha":null,"homepage":"","language":"PureScript","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/justinwoo.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}},"created_at":"2019-02-19T00:06:52.000Z","updated_at":"2021-12-15T13:00:06.000Z","dependencies_parsed_at":"2022-08-30T22:30:52.128Z","dependency_job_id":null,"html_url":"https://github.com/justinwoo/purescript-kishimen","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/justinwoo/purescript-kishimen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-kishimen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-kishimen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-kishimen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-kishimen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinwoo","download_url":"https://codeload.github.com/justinwoo/purescript-kishimen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-kishimen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276375474,"owners_count":25631315,"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-09-22T02:00:08.972Z","response_time":79,"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":["purescript"],"created_at":"2024-10-10T23:44:20.082Z","updated_at":"2025-09-22T08:56:09.605Z","avatar_url":"https://github.com/justinwoo.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PureScript-Kishimen\n\n## aka PureScript-Dan-Abramov\n\n![](https://i.imgur.com/SiCbrx8.jpg) ![](https://i.imgur.com/MNr1Hzr.jpg)\n\nSum types with Generics-Rep instances to Variant for free!\n\n## Usage\n\nFirst, make a sum type of zero or one argument constructors, and derive generic:\n\n```purs\ndata Fruit = Apple | Banana Int | Kiwi String\nderive instance genericFruit :: Generic Fruit _\n```\n\nThen use `genericSumToVariant`:\n\n```purs\nmain :: Effect Unit\nmain = do\n  logShow $ genericSumToVariant Apple\n  logShow $ genericSumToVariant (Banana 3)\n  logShow $ genericSumToVariant (Kiwi \"green\")\n\n  -- results:\n  -- (inj @\"Apple\" {})\n  -- (inj @\"Banana\" 3)\n  -- (inj @\"Kiwi\" \"green\")\n\n  log $ JSON.writeJSON $ genericSumToVariant Apple\n  log $ JSON.writeJSON $ genericSumToVariant (Banana 3)\n  log $ JSON.writeJSON $ genericSumToVariant (Kiwi \"green\")\n\n  -- results:\n  -- {\"type\":\"Apple\",\"value\":{}}\n  -- {\"type\":\"Banana\",\"value\":3}\n  -- {\"type\":\"Kiwi\",\"value\":\"green\"}\n```\n\nAmazing!\n\n## How?\n\nYou can see the inferred type in the expectInferred test:\n\n```purs\ntest1 :: Unit\ntest1 = expectInferred expectedP simpleValue\n  where\n    expectedP = Proxy :: _\n      (Variant\n        ( \"Apple\" :: {}\n        , \"Banana\" :: Int\n        , \"Kiwi\" :: String\n        ))\n    simpleValue = genericSumToVariant Apple\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpurescript-kishimen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinwoo%2Fpurescript-kishimen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpurescript-kishimen/lists"}