snaplet-fay: Fay integration for Snap with request- and pre-compilation.

[ bsd3, deprecated, fay, library, snap, web ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated

Fay integration for Snap with request based compilation during development and precompilation in production. For more information, please see https://github.com/bergmark/snaplet-fay.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.1, 0.3.1.0, 0.3.1.1, 0.3.2.0, 0.3.3, 0.3.3.1, 0.3.3.2, 0.3.3.3, 0.3.3.4, 0.3.3.5, 0.3.3.6, 0.3.3.7, 0.3.3.8, 0.3.3.9, 0.3.3.10, 0.3.3.11, 0.3.3.12, 0.3.3.13, 0.3.3.14
Change log CHANGELOG.md
Dependencies aeson (>=0.6 && <1.2), base (>=4.5 && <5), bytestring (>=0.9 && <0.11), configurator (>=0.2 && <0.4), directory (>=1.1 && <1.4), fay (>=0.20 && <0.24), filepath (>=1.3 && <1.5), mtl (>=2.1 && <2.3), snap (>=0.11.1 && <1.1), snap-core (>=0.9.3.1 && <1.1), transformers (>=0.3 && <0.4 || >0.4.1 && <0.6) [details]
License BSD-3-Clause
Author Adam Bergmark
Maintainer adam@bergmark.nl
Revised Revision 1 made by AdamBergmark at 2017-01-11T21:57:56Z
Category Web, Snap, Fay
Home page https://github.com/faylang/snaplet-fay
Bug tracker https://github.com/faylang/snaplet-fay/issues
Source repo head: git clone https://github.com/faylang/snaplet-fay.git
Uploaded by AdamBergmark at 2017-01-02T17:55:35Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 23391 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-01-02 [all 1 reports]

Readme for snaplet-fay-0.3.3.14

[back to package description]

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.