http-pony: A type unsafe http library

[ bsd3, library, network ] [ Propose Tags ]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,
Change log
Dependencies base (>=4.8 && <5), bytestring (>=0.10), exceptions (>=0.8.3), network (>=2.6), pipes (>=4.1), pipes-network (>=0.6), pipes-safe (>=2.2), transformers (>=0.4) [details]
License BSD-3-Clause
Author Jinjing Wang
Category Network
Home page
Uploaded by JinjingWang at 2017-05-27T13:49:42Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 5189 total (22 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-27 [all 1 reports]

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 Hello (hello)
import Network.HTTP.Pony.Serve (run)
import Network.HTTP.Pony.Transformer.HTTP (http)
import Pipes.Safe (runSafeT)

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

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