{"id":16336446,"url":"https://github.com/justinwoo/purescript-ohyes","last_synced_at":"2025-03-20T23:30:51.090Z","repository":{"id":58242337,"uuid":"101516485","full_name":"justinwoo/purescript-ohyes","owner":"justinwoo","description":"A library for generating Typescript types that can be used transparently from Purescript.","archived":false,"fork":false,"pushed_at":"2019-06-17T09:46:21.000Z","size":15,"stargazers_count":68,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T18:48:39.492Z","etag":null,"topics":["codegen","purescript","types","typescript"],"latest_commit_sha":null,"homepage":null,"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":"2017-08-26T22:25:08.000Z","updated_at":"2023-02-02T23:35:09.000Z","dependencies_parsed_at":"2022-08-31T04:22:15.212Z","dependency_job_id":null,"html_url":"https://github.com/justinwoo/purescript-ohyes","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-ohyes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-ohyes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-ohyes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpurescript-ohyes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinwoo","download_url":"https://codeload.github.com/justinwoo/purescript-ohyes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244710485,"owners_count":20497243,"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":["codegen","purescript","types","typescript"],"created_at":"2024-10-10T23:44:11.327Z","updated_at":"2025-03-20T23:30:50.745Z","avatar_url":"https://github.com/justinwoo.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Purescript-OhYes\n\n[![Build Status](https://travis-ci.org/justinwoo/purescript-ohyes.svg?branch=master)](https://travis-ci.org/justinwoo/purescript-ohyes)\n\nA library for generating Typescript types that can be used transparently from Purescript.\n\nSee the blog post here: \u003chttps://github.com/justinwoo/my-blog-posts#you-can-interop-with-typescript-using-purescript-ohyes\u003e\n\nThis is likely not the \"silver bullet\" that you are looking for, but can give you some good ideas on how to get going.\n\n![](http://i.imgur.com/ZlX0iGz.png)\n\nThis library also provides ways for working with typical union type forms of records with a discriminant field by using [Variant](https://github.com/natefaubion/purescript-variant), which uses a record representation with a string literal `type` field and the associated `value` field.\n\n```ts\nexport type VariantTest =\n  | { type: \"a\", value: string }\n  | { type: \"b\", value: number }\n  | { type: \"c\", value: boolean };\n```\n\n## Example\n\nThe [tests](test/Main.purs) generate types and write them to a file, which is then checked with Typescript using [test/test.ts](test/test.ts):\n\n```hs\ntype A =\n  { a :: Number\n  , b :: String\n  , c :: { d :: String }\n  , e :: Array String\n  , f :: Nullable String\n  , g :: Number -\u003e Number -\u003e Number\n  , h :: Fn2 Number Number Number\n  , i :: Fn2 Number (Fn2 Number Number Number) Number\n  }\n\ntype VariantTest = Variant\n  ( a :: String\n  , b :: Number\n  , c :: Boolean\n  )\n\ngenerateTSFile :: _\ngenerateTSFile = writeTextFile UTF8 \"./test/generated.ts\" values\n  where\n    values = format defaultOptions $ intercalate \"\\n\"\n      [ generateTS \"A\" (Proxy :: Proxy A)\n      , generateTS \"VariantTest\" (Proxy :: Proxy VariantTest)\n      ]\n```\n\nGenerated types:\n\n```ts\nexport type A = {\n  a: number,\n  b: string,\n  c: { d: string },\n  e: string[],\n  f: string | null,\n  g: (a: number) =\u003e (a: number) =\u003e number,\n  h: (a: number, b: number) =\u003e number,\n  i: (a: number, b: (a: number, b: number) =\u003e number) =\u003e number\n};\nexport type VariantTest =\n  | { type: \"a\", value: string }\n  | { type: \"b\", value: number }\n  | { type: \"c\", value: boolean };\n```\n\nSee the additional example here: https://github.com/justinwoo/ohyes-demo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpurescript-ohyes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinwoo%2Fpurescript-ohyes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpurescript-ohyes/lists"}