Snap (web framework)

{{Short description|Web development framework in Haskell}}

{{Infobox software

| name = Snap

| logo = Snap Web Framework logo.png

| screenshot =

| caption =

| author = Gregory Collins, Doug Beardsley{{cite web |url=http://snapframework.com/about |title=Snap: A Haskell Web Framework: About |author=Snap Framework Team |website=Snap Framework.com}}

| developer = [http://snapframework.com/about Snap Team]

| released = {{Start date and age|2010|05}}

| latest release version = 1.1.3.2{{cite web |url=https://github.com/snapframework/snap/tags |title=snapframework/snap |author= |website=GitHub.com}}

| latest release date = {{Start date and age|2023|07|19}}

| operating system = Cross-platform: Unix, Unix-like, macOS; Windows NT

| platform = IA-32, x86-64

| language = English

| repo = {{URL|https://github.com/snapframework}}

| programming language = Haskell

| genre = Web framework

| license = BSD

| website = {{URL|snapframework.com}}

}}

Snap is a web framework for developing web applications written in the functional programming language Haskell.{{cite journal

| last1=Collins

| first1=Gregory

| last2=Beardsley

| first2=Doug

| date=January–February 2011

| title=The Snap Framework: A Web Toolkit for Haskell

| url =http://steve.vinoski.net/pdf/IC-Snap_Framework.pdf

| journal=IEEE Internet Computing

| volume=15

| issue=1

| pages=84–87

| doi =10.1109/mic.2011.21

}}{{cite book |last1=Biscardi |first1=Chris |year=2014 |title=Snap for Beginners |url=https://gumroad.com/l/qWMnO |publisher=Gumroad}}

Overview

The Snap framework consists of the following:

  • snap-core,{{cite web |url=http://hackage.haskell.org/package/snap-core |title=snap-core |website=Hackage.org}} a generic Haskell web server API.
  • snap-server,{{cite web |url=http://hackage.haskell.org/package/snap-server |title=snap-server |website=Hackage.org}} a fast{{cite web |url=http://snapframework.com/blog/2010/11/17/snap-0.3-benchmarks |title=Snap 0.3 benchmarks with GHC 7.0.1 |website=Snap Framework.com |access-date=2014-03-02}} HTTP server that implements the snap-core interface.
  • Heist,{{cite web |url=http://snapframework.com/docs/tutorials/heist |title=Snap: A Haskell Web Framework: Heist Tutorial |author=Snap Framework Team |website=Snap Framework.com}} an HTML-based templating system for generating pages that allows you to bind Haskell functionality to HTML tags for a clean separation of view and backend code, much like Lift's snippets. Heist is self-contained and can be used independently.
  • Snaplets,{{cite web |url=http://snapframework.com/snaplets |title=Snap: A Haskell Web Framework: Snaplet Directory |author=Snap Framework Team |website=Snap Framework.com}} a high-level system for building modular web applications.
  • Built-in snaplets for templating, session management, and authentication.
  • Third party snaplets for features including file uploads, database connectivity (PostgreSQL, MongoDB, etc.), generation of JavaScript from Haskell code, and more.
  • The Snap monad for stateful access to HTTP requests and responses.{{cite web |url=http://hackage.haskell.org/package/snap-core-0.9.6.0/docs/Snap-Core.html#t:Snap |title=Snap.Core |website=Hackage.org}}

Snap runs on both Windows NT and Unix-like platforms. Snap uses the [http://okmij.org/ftp/Streams.html#iteratee Iteratee] input/output (I/O) model,{{cite web |url=http://www.computer.org/portal/web/computingnow/content?g=53319&type=article&urlTitle=gregory-collins-on-high-performance-web-apps-with-snap-and-haskell |title=InfoQ Interview: Gregory Collins on High Performance Web Apps with Snap and Haskell|date=Sep 12, 2011}} As of version 1.0, its I/O is implemented with [http://snapframework.com/blog/2013/03/05/announcing-io-streams io-streams].

Usage

Snap is used by Silk,{{cite web |url=https://www.fpcomplete.com/wp-content/uploads/2013/05/Silk%20case%20study.pdf |title=FP Complete Case Study – Silk – Structured Content Management |website=FP Complete |access-date=2014-03-02}} JanRain,{{cite web |url=https://www.fpcomplete.com/wp-content/uploads/2013/05/janrain%20case%20study.pdf |title=FP Complete Case Study – JanRain – User Management System |website=FP Complete |access-date=2014-03-02}}{{cite web |url=http://janrain.com/blog/tutorial-building-a-sample-application-with-haskell-snap-postgresql-and-the-postgresql-simple-snaplet/ |title=Blog tutorial on Snap and PostgreSQL |website=JanRain |access-date=2014-03-02}} Racemetric,{{cite web |url=http://blog.hoersten.co/post/76773146365/haskell-snap-app-in-production |title=Haskell Snap App in Production |last1=Hoersten |first1=Luke |access-date=2014-03-02}} Lee Paste's Financial Blog,{{cite web |url=http://www.lpaste.net/ |title=Lee Paste |website=Lee Paste's Financial Blog}}{{cite web |url=https://github.com/chrisdone/lpaste/blob/master/hpaste.cabal#L102 |title=lpaste source code |last1=Done |first1=Chris |website=GitHub |access-date=2014-03-02}} SooStone Inc, and Group Commerce. Snap is also used as a lightweight, standalone Haskell server. The static site generator Hakyll uses Snap for its preview mode.{{cite web |last1=Van der Jeugt |first1=Jasper |date= |url=http://jaspervdj.be/hakyll/ |title=Hakyll |website=JasperVdJ.be |access-date=2024-11-09}}

Other Haskell web frameworks

  • Yesod (web framework)
  • Servant (web framework)
  • Scotty{{cite web |url=http://hackage.haskell.org/package/scotty |title=scotty: Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp |website=Hackage.org}}
  • Spock{{cite web |url=http://hackage.haskell.org/package/Spock |title=Spock: Another Haskell web framework for rapid development |website=Hackage.org}}
  • MFlow{{cite web |url=http://hackage.haskell.org/package/MFlow |title=MFlow: stateful, RESTful web framework |website=Hackage.org}}
  • Miso{{cite web |url=http://hackage.haskell.org/package/miso |title=miso: A tasty Haskell front-end framework |website=Hackage.org}}

References

{{Reflist}}