{"id":16504778,"url":"https://github.com/abarbu/reason-export","last_synced_at":"2025-10-28T00:32:10.968Z","repository":{"id":56884149,"uuid":"188736201","full_name":"abarbu/reason-export","owner":"abarbu","description":"Create Reason types and JSON encoders/decoders for Haskell types","archived":false,"fork":false,"pushed_at":"2019-06-01T07:54:19.000Z","size":32,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-01T09:51:17.551Z","etag":null,"topics":["haskell","reason","reasonml","servant","web"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","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/abarbu.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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-05-26T22:07:17.000Z","updated_at":"2020-05-26T16:39:12.000Z","dependencies_parsed_at":"2022-08-20T23:40:26.755Z","dependency_job_id":null,"html_url":"https://github.com/abarbu/reason-export","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Freason-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Freason-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Freason-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Freason-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abarbu","download_url":"https://codeload.github.com/abarbu/reason-export/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238578756,"owners_count":19495438,"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":["haskell","reason","reasonml","servant","web"],"created_at":"2024-10-11T15:06:44.902Z","updated_at":"2025-10-28T00:32:10.617Z","avatar_url":"https://github.com/abarbu.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reason Export\n\n[![Build Status](https://travis-ci.org/abarbu/reason-export.svg)](https://travis-ci.org/abarbu/reason-export)\n\u003cimg src=\"https://cdn.svgporn.com/logos/reasonml.svg\" alt=\"reason\" height=\"20\"/\u003e\n\u003cimg src=\"https://www.haskell.org/img/haskell-logo.svg\" alt=\"reason\" height=\"20\"/\u003e\n\nCreate Reason classes and JSON encoders/decoders from Haskell DataTypes.\nOriginally build by converting [elm-export](http://hackage.haskell.org/package/elm-export) to Reason.\n\nMore docs on [Hackage](http://hackage.haskell.org/package/reason-export).\n\n## Usage\n\nIf you're using this package you almost certainly want to use [servant-reason](http://hackage.haskell.org/package/servant-reason) as well. There are tests in both packages\nthat show to use this library.\n\nUsage is trivial, derive `Generic` and `ReasonType`.\n\n```haskell\n{-# LANGUAGE DeriveGeneric #-}\n{-# LANGUAGE DeriveAnyClass #-}\n\nmodule Db where\n\nimport Reason\nimport GHC.Generics\n\ndata Person = Person\n  { id :: Int\n  , name :: Maybe String\n  } deriving (Show, Eq, Generic, ReasonType)\n```\n\nThen you can expose your API:\n\n```haskell\nmodule Main where\n\nimport Data.Proxy\nimport Reason\nimport           Data.Text hiding (intercalate, map)\nimport Db\n\nmain :: IO ()\nmain = do\n  let code = defReasonImports :\n            toReasonTypeSource (Proxy :: Proxy Person) :\n            toReasonDecoderSource (Proxy :: Proxy Person) :\n  writeFile \"client/Types.re\" $ intercalate \"\\n\\n\" $ map unpack code\n```\n\nThat's about it. Just do this for every type that you want to expose. You can make encoders as well, and configure various settings. See [Hackage](http://hackage.haskell.org/package/reason-export).\n\n## Reason setup\n\nThe generated Reason code needs access to [@glennsl/bs-json](https://github.com/glennsl/bs-json). Get the latest install instructions from there, but at the time of writing these were:\n\n```sh\nnpm install --save @glennsl/bs-json\n```\n\nThen add `@glennsl/bs-json` to `bs-dependencies` in your `bsconfig.json`:\n```js\n{\n  ...\n  \"bs-dependencies\": [\"@glennsl/bs-json\"]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarbu%2Freason-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabarbu%2Freason-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarbu%2Freason-export/lists"}