1{-# LANGUAGE QuasiQuotes #-}
3import Control.Monad (msum)
5import Language.Elm (elmFile, elm)
7import qualified Language.Elm as Elm
10elmLoc = "http://f.cl.ly/items/2e3Z3r3v29263U393c3x/elm-min.js"
12elmResponse :: String -- ^ Page title
13 -> String -- ^ elm source
15elmResponse title = toResponse . Elm.toHtml elmLoc title
17-- embedding variables (in this case URLs)
18rootHandler :: ServerPart Response
19rootHandler = ok $ elmResponse "Welcome!" $ elmIndex
24 elmIndex = [elmFile|elm_source/index.elm|]
26-- loading elm source from file
28mouseHandler :: ServerPart Response
29mouseHandler = ok $ elmResponse "Mouse position demo" $
30 [elmFile|elm_source/mouse.elm|]
32clockHandler :: ServerPart Response
33clockHandler = ok $ elmResponse "A clock" $ [elmFile|elm_source/clock.elm|]
35-- embedding elm code inside Haskell using the QuasiQuoter:
37square = rect 200 200 (150,150)
38circle = oval 140 140 (150,150)
39pentagon = ngon 5 60 (150,150)
42 [ outlined black square
43 , filled green pentagon
44 , customOutline [8,4] blue circle
48shapesHandler :: ServerPart Response
49shapesHandler = ok $ elmResponse "Simple shapes" $ shapesPage
52elmExample :: ServerPart Response
54 msum [ nullDir >> rootHandler
55 , dir "mouse" $ nullDir >>
57 , dir "clock" $ nullDir >>
59 , dir "shapes" $ nullDir >>
64main = 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