1{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}
3import Control.Monad (msum)
6import Language.Elm.Quasi
9elmLoc = "https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.3.5.js"
11-- elmResponse is a "nice to have" helper function for compiling
12-- Elm code when using Elm with Happstack. At some point this might
13-- be moved to an elm-happstack package.
14elmResponse :: ElmSource a
15 => String -- ^ Page title
18elmResponse title = toResponse . toHtml elmLoc title
20-- embedding variables (in this case URLs)
21rootHandler :: ServerPart Response
22rootHandler = ok $ elmResponse "Welcome!" $ elmIndex
27 elmIndex = $(elmFile "elm_source/index.elm")
29-- loading elm source from file
31mouseHandler :: ServerPart Response
32mouseHandler = ok $ elmResponse "Mouse position demo"
33 $(elmFile "elm_source/mouse.elm")
35clockHandler :: ServerPart Response
36clockHandler = ok $ elmResponse "A clock" $(elmFile "elm_source/clock.elm")
38-- embedding elm code inside Haskell using the QuasiQuoter:
40square = rect 200 200 (150,150)
41circle = oval 140 140 (150,150)
42pentagon = ngon 5 60 (150,150)
45 [ outlined black square
46 , filled green pentagon
47 , customOutline [8,4] blue circle
51shapesHandler :: ServerPart Response
52shapesHandler = ok $ elmResponse "Simple shapes" $ shapesPage
55elmExample :: ServerPart Response
57 msum [ nullDir >> rootHandler
58 , dir "mouse" $ nullDir >>
60 , dir "clock" $ nullDir >>
62 , dir "shapes" $ nullDir >>
67main = simpleHTTP nullConf {port = 3000} elmExample
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list