Safe Haskell | None |
---|---|
Language | Haskell2010 |
Snaplet that serves javascript files compiled with ghcjs (https://github.com/valderman/ghcjs-compiler). This Snaplet is meant to be used for development. You can work on client side Haskell code and immedietely test the code with a simple browser reload. It certainly adds some overhead and is not meant to be used in production websites.
Usage:
Put haskell source files in the snaplet path (e.g. $ROOT/snaplets/ghcjs
).
For every such haskell file there will be a new javascript file available via
http.
- Other files won't be served through http. The snaplet will
mzero
on .hs, .hi, .o and all other files. - If any haskell file in the snaplet path is newer than the requested javascript file, it will be recompiled. The ghcjs snaplet does not track haskell import dependencies: recompilation happens whether the js file is requested or not.
- If ghcjsc exits with an error code this snaplet will serve a special javascript file that contains the error message as a comment and a javascript command that will raise the error message as a javascript exception.
Please add such a handler to your routes:
[ ... , ("" , with ghcjs ghcjsServe) ]
- data GHCJS
- snapletArgs :: Lens' GHCJS [String]
- initialize :: [String] -> SnapletInit app GHCJS
- ghcjsServe :: Handler app GHCJS ()
Documentation
snapletArgs :: Lens' GHCJS [String] Source
initialize :: [String] -> SnapletInit app GHCJS Source
Initializes the ghcjs snaplet. Use it with e.g. nestSnaplet
.
ghcjsServe :: Handler app GHCJS () Source