Deprecated

snaplet-fay

Fay integration for Snap with request- and pre-compilation.

https://github.com/faylang/snaplet-fay

Version on this page:0.3.3.12@rev:1
LTS Haskell 6.35:0.3.3.14@rev:1
Stackage Nightly 2017-01-17:0.3.3.14@rev:1
Latest on Hackage:0.3.3.14@rev:1

See all snapshots snaplet-fay appears in

BSD-3-Clause licensed by Adam Bergmark
Maintained by [email protected]
This version can be pinned in stack with:snaplet-fay-0.3.3.12@sha256:9986472ebb3e6f8761004d4d2d3da8e937b786428ffaf39a338eabd364c4a974,1932

Module documentation for 0.3.3.12

Snaplet Fay

Changelog

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.

Features

  • Compile and serve fay files on request, no need to restart the snap server.
  • Production mode to pre-compile all fay files.
  • 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.
  • Share Fay source files between Haskell and Fay.
  • Automatically encode/decode records shared between Snap and Fay by using the fayax functions.

Installation

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

Everything else is available on hackage:

cabal install snaplet-fay

Example Usage

Site.hs:

import Snap.Snaplet.Fay

routes = [..., ("/fay", with fay fayServe)]

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

Application.hs:

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.

Any requests to the specified directory (in this case /fay/) will compile the appropriate Fay file and serve it.

Example Application

There is an example available in the example directory. It requires fay-jquery hackage github.

Development Status

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

Contributions

Fork on!

Any enhancements are welcome.

The github master may require the latest fay master, available at faylang/fay.

Contact

File an issue, e-mail or visit #fay @ irc.freenode.net.

Changes

Changelog

0.3.3.12

  • Allow aeson 0.9.*

0.3.3.11

  • Allow snap 0.14.*

0.3.3.10 (2015-02-11)

  • Allow fay 0.23.*

0.3.3.9 (2015-01-05)

  • Allow fay 0.22.*

0.3.3.8 (2014-10-11)

  • Allow fay 0.21.*

0.3.3.7 (2014-05-12)

  • Take HASKELL_PACKAGE_SANDBOX into account when compiling Fay code
Revision 1
  • Allow configurator == 0.3.*

0.3.3.6 (2014-05-11)

  • Allow mtl 2.2.*
  • Allow transformers >= 0.4.1 && < 0.5

0.3.3.5 (2014-04-29)

  • Update to fay 0.20

0.3.3.4 (2014-01-19)

  • Allow aeson 0.7.*

0.3.3.3 (2014-01-17)

  • Allow fay 0.19.*

0.3.3.2 (2013-11-07)

  • example: Allow fay-text 0.3
  • example: Remove bounds on snaplet-fay

0.3.3.1 (2013-11-07)

  • Allow fay-jquery 0.5

0.3.3 (2013-11-07)

  • Format Fay compile errors using Fay’s builtin (doesn’t break on apostrophes)
  • Only treat compile errors as Success in development mode (for in browser error reporting)
  • Fixes a bug where error strings would be encoded twice
  • Requires fay 0.18
  • Update example for fay-jquery 0.4
  • Upper bounds for dependencies

0.3.2.0

  • Expose Snap.Snaplet.Fay.Internal

0.3.1.1

  • Hackage version now includes the example application
  • Updated repository location

0.3.1.0

  • Add packages flag in the config which lets you use other fay packages without using includeDirs
  • On errors in development mode a js file is produced that prints the error to the console (Thanks Daniel Bruegmann)

0.3.0.1

  • Bump to support snap 0.10 and fay 0.11