Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
ghc-fn
ghc-fn.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ghc-fn.spec of Package ghc-fn
# # spec file for package ghc-fn # # Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # %global pkg_name fn %bcond_with tests Name: ghc-%{pkg_name} Version: 0.3.0.1 Release: 0 Summary: A functional web framework License: ISC Group: Development/Libraries/Haskell URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel BuildRequires: ghc-blaze-builder-devel BuildRequires: ghc-bytestring-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-filepath-devel BuildRequires: ghc-http-types-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-text-devel BuildRequires: ghc-unordered-containers-devel BuildRequires: ghc-wai-devel BuildRequires: ghc-wai-extra-devel %if %{with tests} BuildRequires: ghc-hspec-devel %endif %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):/ ' #!%{_bindir}/env stack -- stack --resolver lts-5.5 --install-ghc runghc --package fn --package warp {-# LANGUAGE OverloadedStrings #-} import Data.Monoid ((<>)) import Data.Text (Text) import Network.Wai (Response) import Network.Wai.Handler.Warp (run) import Web.Fn data Ctxt = Ctxt { _req :: FnRequest } instance RequestContext Ctxt where   getRequest = _req   setRequest c r = c { _req = r } initializer :: IO Ctxt initializer = return (Ctxt defaultFnRequest) main :: IO () main = do ctxt <- initializer   run 3000 $ toWAI ctxt site site :: Ctxt -> IO Response site ctxt = route ctxt [ end ==> indexH   , path "echo" // param "msg" ==> echoH   , path "echo" // segment ==> echoH   ]   `fallthrough` notFoundText "Page not found." indexH :: Ctxt -> IO (Maybe Response) indexH _ = okText "Try visiting /echo?msg='hello' or /echo/hello" echoH :: Ctxt -> Text -> IO (Maybe Response) echoH _ msg = okText $ "Echoing '" <> msg <> "'." ' 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. %package devel Summary: Haskell %{pkg_name} library development files Group: Development/Libraries/Haskell Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} Requires(postun): ghc-compiler = %{ghc_version} %description devel This package provides the Haskell %{pkg_name} library development files. %prep %setup -q -n %{pkg_name}-%{version} %build %ghc_lib_build %install %ghc_lib_install %check %cabal_test %post devel %ghc_pkg_recache %postun devel %ghc_pkg_recache %files -f %{name}.files %doc LICENSE %files devel -f %{name}-devel.files %doc CHANGELOG.md README.md %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor