http-pony: A type unsafe http library

[ bsd3, library, network ] [ Propose Tags ]

[Skip to Readme]
Versions [faq],,,,,,,
Change log
Dependencies attoparsec (>=0.13), base (==4.9.*), bytestring (==0.10.*), case-insensitive (>=1.2), network (>=2.6), pipes (>=4.1), pipes-attoparsec (>=0.5), pipes-network (>=0.6), pipes-parse (>=3.0), pipes-safe (>=2.2), transformers (>=0.5) [details]
License BSD-3-Clause
Author Jinjing Wang
Category Network
Home page
Uploaded by JinjingWang at 2016-09-19T19:54:45Z
Distributions NixOS:
Downloads 4416 total (101 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2016-09-19 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for http-pony-

[back to package description]


Let's write a hello world app.

{-# LANGUAGE OverloadedStrings #-}

module Hello where

import Pipes (yield)

hello _ = pure ("HTTP/1.1 200 OK", [], yield "hello world\n")

Note, we are not importing any interface!

If we take a closer look at the type of hello:

Prelude Hello> :t hello
  :: (Applicative f, Data.String.IsString a, Data.String.IsString t,
      Monad m) =>
    t2 -> f (t, [t1], Pipes.Internal.Proxy x' x () a m ())

This is a pure app!

Shall we run it?

{-# LANGUAGE OverloadedStrings #-}

module RunHello where

import Network.HTTP.Pony.Serve (run, http)
import Pipes.Safe (runSafeT)
import PonyHello (ponyHello)

main :: IO ()
main = (runSafeT . run "localhost" "8080" . http) ponyHello

Test it:

# the above files are mirrored in `./test`
runghc -isrc -itest test/RunHello.hs

# open another terminal
curl localhost:8080 -i

# output:

> HTTP/1.1 200 OK
> hello world

wow ~

Exercise: write a tcp cat