Skip to content

Repository files navigation

Fn (eff-enn) - a functional web framework.

Or, how to do away with the monad transformers, and just use plain functions.

Example

See the example directory for a full example, but a minimal application is the following:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
importControl.LensimportData.MonoidimportData.Text (Text)
importqualifiedData.TextasTimportNetwork.HTTP.TypesimportNetwork.WaiimportNetwork.Wai.Handler.WarpimportqualifiedNetwork.Wai.UtilasWimportWeb.FndataCtxt=Ctxt{_req::Request}
makeLenses ''Ctxt
instanceRequestContextCtxtwhere
requestLens = req
initializer::IOCtxt
initializer =return (Ctxt defaultRequest)
main::IO()
main =do context <- initializer
run 8000$ toWAI context app
app::Ctxt->IOResponse
app ctxt =
route ctxt [ end ==> index
, path "foo"// segment // path "baz"// param "id"==> handler]
`fallthrough` notFoundText "Page not found."index::IO (MaybeResponse)
index = okText "This is the index page! Try /foo/bar/baz?id=10"handler::Text->Int->Ctxt->IO (MaybeResponse)
handler fragment i _ = okText (fragment <>" - "<>T.pack (show i))

About

A functional web framework

Topics

Resources

Stars

34 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages