Full-stack web app, built in a typesafe functional way, where servant-to-elm generates types, decoders/encoders, and fetching functions from Haskell types and Servant endpoint definition to Elm.๐ค๐ป
This example is a full-stack web application, built in a typesafe functional way.
What's cool here is that servant-to-elm does the job of generating types and decoders/encoders from Haskell types and Servant definition to Elm, which not only catches regressions in the compile-time but also provides ready (and highly configurable) Elm functions to fetch necessary data from the server.
cd backend && stack run codegen
cd frontend && npm i
File > Open Workspace
and choose servant-to-elm-example.code-workspace
. In this scenario, VSCode will work correctly with both languages simultaneously. Also, the editor may recommend extensions, and installing them is a wise choice.cd backend && stack run server
cd frontend && npm start
backend/src/DomainModel.hs
:
Book
, NewBook
, and NewBookAuthor
types and corresponding generated Elm module)typeDefinitions
list - jsonDefinitions @YourNewType
backend/src/Server.hs
or wherever it's intended tobackend/src/Codegen.hs
. In this example, only the frontend/src/Api
directory is removed before writing new files.