- This is a template for using servant and elm
- This template is built with:
- Stack -- build the haskell project
- Postgres -- database
- Elm -- front end
- Webpack -- bundling tool
- Typescript -- for frontend javascript such as embedding your elm app and ports
- Ruby -- for database migrations and build tool
- npm -- node package manager
- This app is just a raw skeleton to use haskell for your backend and elm for your front end.
- The example posts a dice to the server, rolls that dice, then sends back the result
- The code-generator generates your elm types, decoders, encoders, and api endpoints from your haskell types
- Install NodeJS v6.9+
choco install nodejs-lts
- Install Elm v0.18
choco install elm-platform
- Install Ruby
choco install ruby
- Install Postgres
choco install postgresql
- Install Stack
choco install haskell-stack
- Run stack setup
stack setup
- Install hpack
stack install hpack
- Install intero
stack install intero
- Install typescript globally
npm install -g typescript
- Run
rake npm
- Run
rake elm
- Install pg
gem install pg
- Install standalone_migrations
gem install standalone_migrations
- run
rake watch
- this will build your project and enable hot reloading
- IDE
- I recommend using VS Code with the following plugins:
- language-haskell
- Vans.haskero
- sbrink.elm
- abadi199.elm-format
- realazy.elmx
- monofon.hindent-format
- rebornix.ruby
- groksrc.ruby
- hoovercj.ruby-linter
- mrmInc.vscode-scss
- emmanuelbeziat.vscode-great-icons
- joeandaverde.vscode-elm-jump
- siegebell.prettify-symbols-mode
- Run On Save / Hindent
- To format your elm code on save, you need to use runonsave combined with hindent
- monofon.hindent-format
- emeraldwalk.runonsave
- update your vscode settings with
"emeraldwalk.runonsave": { "commands": [ { "match": ".hs", "cmd": "cd ${fileDirname} && hindent ${file}" } ] }
- To format your elm code on save, you need to use runonsave combined with hindent
- Elm Format on Save
npm install elm-format
- update your vscode settings with
"elm.formatOnSave": true
- I recommend using VS Code with the following plugins:
- run
rake build
- this will build your app for production by generating your dist folder
- then run
rake serve
to serve your production app
- JQuery
- Bootstrap
- Font Awesome
- Tether
client
-- all client side codedb
-- all database migrationsserver
-- all server side code
- POSTGRES
POSTGRES_HOST
-- postgres hostPOSTGRES_PORT
-- postgres portPOSTGRES_USER
-- postgres usernamePOSTGRES_PASS
-- postgres passwordPOSTGRES_DATABASE
-- postgres database
- Creating a new migration
rake db_create_migration name={name}
- this will create a new db migration in db/migrate
- Resetting your db
rake rebuild_db_dev
- this will drop your database and recreate it
- note: you need to have the correct
db_name
,user_name
, anduser_password
in the config.yml for this to work
- Running the migrations
- running your app will automatically run the postgres migrations when your servant server starts up.
- The environment variables need to be set up or the defaults need to be set to match your postgres credentials for this to work.