{"id":20132522,"url":"https://github.com/aherrmann/example-servant-elm","last_synced_at":"2025-04-09T16:53:33.821Z","repository":{"id":71967652,"uuid":"378363723","full_name":"aherrmann/example-servant-elm","owner":"aherrmann","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-11T20:47:17.000Z","size":357,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T19:04:14.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/aherrmann.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},"funding":{"open_collective":"bazel-rules-authors-sig"}},"created_at":"2021-06-19T08:34:49.000Z","updated_at":"2023-12-17T21:09:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f7e091d-d2cf-4cdd-9b92-0c18f12352ac","html_url":"https://github.com/aherrmann/example-servant-elm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fexample-servant-elm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fexample-servant-elm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fexample-servant-elm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fexample-servant-elm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aherrmann","download_url":"https://codeload.github.com/aherrmann/example-servant-elm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248073718,"owners_count":21043474,"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-13T20:53:53.421Z","updated_at":"2025-04-09T16:53:33.815Z","avatar_url":"https://github.com/aherrmann.png","language":"Haskell","funding_links":["https://opencollective.com/bazel-rules-authors-sig"],"categories":[],"sub_categories":[],"readme":"# ZuriHac 2021 - Building Haskell with Bazel\n\nWorkshop on porting a Haskell and Elm project to be built with Bazel.\n\n- [Slides](./slides/zurihac_2021.pdf)\n- [Recording](https://youtu.be/GV5MG05rWO0)\n- [Completed build](https://github.com/aherrmann/example-servant-elm/tree/solution)\n\n## Setup\n\nThe project contains a [`Dockerfile`](docker/Dockerfile) that installs all\nrequired dependencies. Use as follows:\n\n1. Build the Docker image\n    ```\n    $ docker build -t zurihac2021 docker\n    ```\n2. Start a Docker container as a daemon\n    ```\n    $ docker run -d -v \"$PWD:/work\" --network host -it zurihac2021\n    cbc8a033b90dec3df4b470b157903fc23cc4c1a956a1370c8c6ca55b9aa63ef2\n    ```\n3. Open a shell session in the Docker container (can be executed multiple times)\n    ```\n    $ docker exec -it -w /work --detach-keys=\"ctrl-@\" cbc8a033b90d bash\n    ```\n\nYou can query for the Docker container's id using\n```\n$ docker ps\nCONTAINER ID   IMAGE         COMMAND   ...\ncbc8a033b90d   zurihac2021   \"bash\"    ...\n```\n\nYou can then stop that container using\n```\n$ docker stop cbc8a033b90d\n```\n\n## Generate Elm Repositories\n\nTo generate an `elm_repository` for each dependency in `client/elm.json` use\n```\n$ bazel run //scripts:generate_elm_repositories -- client/elm.json -o elm_repositories.bzl\n```\n\n## Build and Test\n\nTo build a particular target or all targets\n```\n$ bazel build //server/src:server\n$ bazel build //...\n```\n\nTo run a particular test or all tests\n```\n$ bazel test //server/test:spec\n$ bazel test //...\n```\n\n## Run the Server\n\nTo run the Haskell server\n```\n$ bazel run //server/src:server\nlistening on port 3000...\n```\n\nThen browse to http://localhost:3000.\n\n## Interactive Development\n\nYou can use [`bazel-watcher`][bazel-watcher] to continuously rebuild the\nassets whenever any of its sources change, like so.\n\n```\n$ ibazel build //assets\n```\n\nYou can use [`ghcid`][ghcid] to continuously reload the backend whenever\nany of its sources change, like so.\n\n```\n$ bazel build @stackage-exe//ghcid\n$ ASSETS_DIR=bazel-bin/assets \\\n    ghcid --command=\"bazel run //server/src:serve@ghci\" \\\n      --test=Main.main \\\n      --reload=bazel-bin/assets\n```\n\nThis will load the Haskell code into a GHCi session and run the server in\nthe interpreter. It will reload the session and restart the server\nwhenever any of the Haskell source files or the assets change.\n\nNote, if the dependency graph changes, e.g. when you edit a `BUILD.bazel`\nfile, then you will have to restart `ghcid` itself.\n\n[bazel-watcher]: https://github.com/bazelbuild/bazel-watcher#readme\n[ghcid]: https://github.com/ndmitchell/ghcid#readme\n\n## Haskell Servant and Elm Example\n\nBased on [`haskell-servant/example-servant-elm`](https://github.com/haskell-servant/example-servant-elm.git).\n\nThis example project illustrates how to set up a project that:\n\n- Uses haskell and `servant` as a backend exposing a JSON api\n  (and serving some files).\n- Uses elm to write the frontend.\n- Uses `servant-elm` to generate client functions in elm for the JSON api.\n  This means that mismatches regarding the JSON api will be detected statically.\n- Allows a very fast development cycle: You can type-check the server and\n  client code in a very short amount of time.\n\n### More examples\n\nThis repository demonstrates a servant backend and an elm frontend. More code generation examples can be found in [`haskell-servant/servant-elm`](https://github.com/haskell-servant/servant-elm/tree/master/examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Fexample-servant-elm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faherrmann%2Fexample-servant-elm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Fexample-servant-elm/lists"}