{"id":15010973,"url":"https://github.com/abarbu/servant-reason","last_synced_at":"2025-08-02T01:11:42.832Z","repository":{"id":56877622,"uuid":"188738113","full_name":"abarbu/servant-reason","owner":"abarbu","description":"Automatically derive bindings for Servant APIs in Reason","archived":false,"fork":false,"pushed_at":"2019-06-01T07:55:55.000Z","size":18,"stargazers_count":12,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-23T20:37:21.583Z","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":"bsd-3-clause","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:34:17.000Z","updated_at":"2020-10-21T23:00:16.000Z","dependencies_parsed_at":"2022-08-20T10:40:35.977Z","dependency_job_id":null,"html_url":"https://github.com/abarbu/servant-reason","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Fservant-reason","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Fservant-reason/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Fservant-reason/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abarbu%2Fservant-reason/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abarbu","download_url":"https://codeload.github.com/abarbu/servant-reason/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088559,"owners_count":21045740,"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-09-24T19:37:59.442Z","updated_at":"2025-04-09T18:40:39.527Z","avatar_url":"https://github.com/abarbu.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Servant Reason\n\n[![Build Status](https://travis-ci.org/abarbu/servant-reason.svg)](https://travis-ci.org/abarbu/servant-reason)\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\nAutomatically derive bindings for Servant APIs in Reason.  Originally build by\nconverting [servant-elm](http://hackage.haskell.org/package/servant-elm) to\nReason. Types are generated using\n[reason-export](https://github.com/abarbu/reason-export).\n\nMore docs on [Hackage](http://hackage.haskell.org/package/servant-reason).\n\nA full example of how to integrate Servant and Reason is available at\n[servant-reason-example](https://github.com/abarbu/servant-reason-example).\n\n## Usage\n\nRun the tests if you want a concrete example. They will build a _test-cache\ndirectory that contains a sample Reason repository for a servant API. test also\ncontain example output files for different kinds of bindings.\n\nUsage is simple and automatic. If you have an API like the one below\n\n```haskell\n{-# LANGUAGE DataKinds         #-}\n{-# LANGUAGE DeriveGeneric     #-}\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE TypeOperators     #-}\n\nimport           Reason          (Spec (Spec), specsToDir, toReasonDecoderSource,\n                               toReasonTypeSource)\nimport           GHC.Generics (Generic)\nimport           Servant.API  ((:\u003e), Capture, Get, JSON)\nimport           Servant.Reason  (ReasonType, Proxy (Proxy), defReasonImports,\n                               generateReasonForAPI)\n\ndata Book = Book\n    { name :: String\n    } deriving (Generic)\n\ninstance ReasonType Book\n\ntype BooksApi = \"books\" :\u003e Capture \"bookId\" Int :\u003e Get '[JSON] Book\n```\n\nYou can expose your API to reason with:\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 Book)\n             : toReasonDecoderSource (Proxy :: Proxy Book)\n             : generateReasonForAPI  (Proxy :: Proxy BooksApi))\n  writeFile \"Api.re\" $ intercalate \"\\n\\n\" $ map unpack code\n```\n\nThat's it. You can now include `Api.re` in a Reason project.\n\n## Reason setup\n\nThe generated code needs access to two Reason libraries\n[@glennsl/bs-json](https://github.com/glennsl/bs-json) and\n[bs-fetch](https://github.com/reasonml-community/bs-fetch). Get the latest\ninstall instructions from the upstream repos, but at the time of writing these\nwere:\n\n```sh\nnpm install --save @glennsl/bs-json\nnpm install --save bs-fetch\n```\n\nThen add `@glennsl/bs-json` and `bs-fetch` to `bs-dependencies` in your `bsconfig.json`:\n```js\n{\n  ...\n  \"bs-dependencies\": [\"@glennsl/bs-json\", \"bs-fetch\"]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarbu%2Fservant-reason","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabarbu%2Fservant-reason","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabarbu%2Fservant-reason/lists"}