-
Notifications
You must be signed in to change notification settings - Fork 0
Elm with Yesod: Getting Started
This page describes how to get started serving Elm code with a Yesod backend.
After installing the yesod-platform
with:
cabal install yesod-platform
the first thing you'll need is the elm-yesod
package (docs) which makes it possible to easily embed Elm in Yesod. This package allows you to write Elm code within Haskell programs using QuasiQuoting. It also allows you to serve .elm
files with minimal effort. Install it with:
cabal install elm-yesod
Great, now we actually need to set up a server. To make this easier, we have provided an example server that covers the basics of serving Elm with Yesod. To get this example up and running on your machine, download the Elm project here. After downloading and decompressing, navigate to the Examples/elm-yesod/
directory which should contain the example Yesod code in Main.hs
. Start your server with:
runhaskell Main.hs
Then navigate to localhost:3000 to see your website. Each page is written entirely in Elm. You are now serving Elm with Yesod.
Now that we know everything is working, take a look at Main.hs
. This file shows all of the functionality of elm-yesod
with comments along the way. It will show you the details of how to embed Elm in any Yesod application.