|
| 1 | +# todo app |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +A minimal todo app implemented in [Haskell][haskell] using [Servant][servant] |
| 6 | +on the backend, and in [Elm][elm] on the frontend, built with [Bazel][bazel] |
| 7 | +using [`rules_haskell`][rules_haskell] and [`rules_elm`][rules_elm]. |
| 8 | + |
| 9 | +[haskell]: https://www.haskell.org/ |
| 10 | +[servant]: https://hackage.haskell.org/package/servant |
| 11 | +[elm]: https://elm-lang.org/ |
| 12 | +[bazel]: https://bazel.build/ |
| 13 | +[rules_haskell]: https://haskell.build/ |
| 14 | +[rules_elm]: https://github.com/EdSchouten/rules_elm |
| 15 | + |
| 16 | +## Requirements |
| 17 | + |
| 18 | +You will need the [dependencies of `rules_haskell`][dependencies] |
| 19 | +installed on your system to build. |
| 20 | + |
| 21 | +On MacOS you also need to set the following environment variable: |
| 22 | + |
| 23 | +``` |
| 24 | +export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 |
| 25 | +``` |
| 26 | + |
| 27 | +[dependencies]: https://rules-haskell.readthedocs.io/en/latest/haskell.html#before-you-begin |
| 28 | + |
| 29 | +## Instructions |
| 30 | + |
| 31 | +Execute the following command to build and start the app: |
| 32 | + |
| 33 | +``` |
| 34 | +$ bazel run //:backend |
| 35 | +``` |
| 36 | + |
| 37 | +Then browse to `http://localhost:8080` to use the app. |
| 38 | + |
| 39 | +## Interactive Development |
| 40 | + |
| 41 | +You can use [`bazel-watcher`][bazel-watcher] to continuously rebuild the |
| 42 | +frontend whenever any of its sources change, like so. |
| 43 | + |
| 44 | +``` |
| 45 | +$ ibazel build //frontend |
| 46 | +``` |
| 47 | + |
| 48 | +You can use [`ghcid`][ghcid] to continuously reload the backend whenever |
| 49 | +any of its sources change, like so. |
| 50 | + |
| 51 | +``` |
| 52 | +$ ghcid --command="bazel run //backend:backend@ghci" \ |
| 53 | + --test=Main.main \ |
| 54 | + --setup=":set args --assets bazel-bin/frontend/frontend.tar" \ |
| 55 | + --reload=bazel-bin/frontend/frontend.tar |
| 56 | +``` |
| 57 | + |
| 58 | +This will load the Haskell code into a GHCi session and run the server in |
| 59 | +the interpreter. It will reload the session and restart the server |
| 60 | +whenever any of the Haskell source files or the frontend bundle changes. |
| 61 | + |
| 62 | +Note, if the dependency graph changes, e.g. when you edit a `BUILD.bazel` |
| 63 | +file, then you will have to restart `ghcid` itself. |
| 64 | + |
| 65 | +[bazel-watcher]: https://github.com/bazelbuild/bazel-watcher#readme |
| 66 | +[ghcid]: https://github.com/ndmitchell/ghcid#readme |
0 commit comments