name:                fn
version:             0.3.0.2
synopsis:            A functional web framework.
description:
  A Haskell web framework where you write plain old functions.
  .
  /Provided you have/ <https://github.com/commercialhaskell/stack#readme stack> /installed, you can run this example like a shell script (it'll listen on port 3000):/
  .
  @
    #!\/usr\/bin\/env stack
    \-\- stack --resolver lts-5.5 --install-ghc runghc --package fn --package warp
    &#123;-&#35; LANGUAGE OverloadedStrings &#35;-&#125;
    import Data.Monoid ((&#60;&#62;))
    import Data.Text (Text)
    import Network.Wai (Response)
    import Network.Wai.Handler.Warp (run)
    import Web.Fn
    .
    data Ctxt = Ctxt &#123; _req :: FnRequest &#125;
    instance RequestContext Ctxt where
    &#32; getRequest = _req
    &#32; setRequest c r = c &#123; _req = r &#125;
    .
    initializer :: IO Ctxt
    initializer = return (Ctxt defaultFnRequest)
    .
    main :: IO ()
    main = do ctxt <- initializer
    &#32;         run 3000 $ toWAI ctxt site
    .
    site :: Ctxt -> IO Response
    site ctxt = route ctxt [ end                        ==> indexH
    &#32;                      , path &#34;echo&#34; \/\/ param &#34;msg&#34; ==> echoH
    &#32;                      , path &#34;echo&#34; \/\/ segment     ==> echoH
    &#32;                      ]
    &#32;                 \`fallthrough\` notFoundText &#34;Page not found.&#34;
    .
    indexH :: Ctxt -> IO (Maybe Response)
    indexH _ = okText &#34;Try visiting \/echo?msg='hello' or \/echo\/hello&#34;
    .
    echoH :: Ctxt -> Text -> IO (Maybe Response)
    echoH _ msg = okText $ &#34;Echoing '&#34; &#60;&#62; msg &#60;&#62; &#34;'.&#34;

  @
  .
  .
  Fn lets you write web code that just looks like normal Haskell code.
  .
    * An application has some \"context\", which must contain a @Request@,
      but can contain other data as well, like database connection pools,
      etc. This context will be passed to each of your handlers, updated
      with the current HTTP Request.
  .
    * Routes are declared to capture parameters and/or segments of the url,
      and then routed to handler functions that have the appropriate number
      and type of arguments. These functions return @IO (Maybe Response)@,
      where @Nothing@ indicates to Fn that you want it to keep looking for
      matching routes.
  .
    * All handlers just use plain old @IO@, which means it is easy to call
      them from GHCi, @forkIO@, etc.
  .
    * All of this is a small wrapper around the WAI interface, so you have
      the flexilibility to do anything you need to do with HTTP.
  .
  The name comes from the fact that Fn emphasizes functions (over monads),
  where all necessary data is passed via function arguments, and control
  flow is mediated by return values.

homepage:            http://github.com/positiondev/fn#readme
license:             ISC
license-file:        LICENSE
author:              Daniel Patterson <dbp@dbpmail.net>
maintainer:          workers@positiondev.com
copyright:           2016 Position Development, LLC.
category:            Web
build-type:          Simple
extra-source-files:  CHANGELOG.md
                     README.md
cabal-version:       >=1.10

library
  hs-source-dirs:      src
  exposed-modules:     Web.Fn
  build-depends:       base >= 4.7 && < 6
                     , wai >= 3
                     , wai-extra >= 3
                     , http-types
                     , text
                     , blaze-builder
                     , bytestring
                     , unordered-containers
                     , filepath
                     , directory
                     , resourcet
  default-language:    Haskell2010
  ghc-options:         -Wall

test-suite fn-test
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Spec.hs
  build-depends:       base
                     , fn
                     , hspec
                     , text
                     , http-types
                     , wai
                     , wai-extra
                     , unordered-containers
                     , filepath
                     , directory
                     , resourcet
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall
  default-language:    Haskell2010

source-repository head
  type:     git
  location: https://github.com/positiondev/fn