Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fay integration for Snap that provides automatic (re)compilation during development
JavaScript Haskell Smarty CSS HTML
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Snaplet Fay

Snaplet Fay integrates Snap with Fay. Snap is a Haskell web framework and Fay is a compiler from a proper subset of Haskell to JavaScript. Snaplet Fay integrates them nicely with each other allowing automatic (re)compilation of Fay source files. Snap provides this for both static content and haskell sources preventing web server restarts and here we add Fay to this list as well. This lets us write both front and back-end code in Haskell.


  • Compile and serve fay files automatically, no need to restart the snap server.
  • Uses Fay's pretty print option (js-beautify) to create JS files that are easier to debug.
  • Writes JS to disk to allow reading the generated source.


You will need Haskell, Snap and Fay installed. The simplest way to get up and running with Haskell is to install The Haskell Platform.

Snap and Fay are available on hackage:

cabal install snap fay

Clone this repository and install the package:

cabal install

Example Usage


import Snap.Snaplet.Fay

app :: SnapletInit App App
app = makeSnaplet "app" "A snaplet example application." Nothing $ do
  fay' <- nestSnaplet "fay" fay initFay
  return $ App { _fay = fay' }


import Snap.Snaplet.Fay

data App = App { _fay :: Snaplet Fay }

makeLens ''App

Run your application now.

A snaplet config file will be generated at snaplets/fay/devel.cfg the first time your application initializes the snaplet. The defaults are the recommended ones for development.

Place your Fay .hs files in snaplets/fay/src. Note that a default devel.cfg will not be created if you have already created the fay directory, if this happens to you move snaplets/fay, start your application, and then move the files back into snaplets/fay.

Development Status

Snaplet Fay is functioning and will be updated to keep up with both Snap and Fay.


Fork on!

Any enhancements are welcome.

The github master usually requires the latest fay master, available at faylang/fay.

To run the tests, do:

cabal configure -ftest
cabal build


File an issue, e-mail or visit #fay @

Something went wrong with that request. Please try again.