packages feed

sockets-and-pipes-0.1: sockets-and-pipes.cabal

cabal-version: 2.0
build-type: Simple

name: sockets-and-pipes
version: 0.1
synopsis: Support for the Sockets and Pipes book
category: HTTP, Network, Streaming, Text
license: Apache-2.0
license-file: license.txt
author: Chris Martin, Julie Moronuki
maintainer: Joy of Haskell <hello@joyofhaskell.com>

-- GHC 9.0 support is held back by the 'base' version; see comments below.
tested-with: GHC == 8.10.3, GHC == 8.8.4, GHC == 8.6.5

description:
    This package contains some utilities that support /Sockets and Pipes/
    (available on <https://leanpub.com/sockets-and-pipes Leanpub>),
    as well as re-exports from all the libraries mentioned in the book.
    .
    == Code in this package
    .
    Original contributions from this package:
    .
        * "SocketsAndPipes.Serve"
    .
    == Chapters
    .
    List of modules that make a significant appearance in each chapter:
    .
    +----+----------------------+----------------------------------+---------------------------------------+
    |    |   Chapter            |          Module                  |               Purpose                 |
    +====+======================+==================================+=======================================+
    |  1 | __Handles__          | "System.IO"                      | Writing to a file                     |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Control.Exception.Safe"         | Using `bracket` to ensure             |
    |    |                      |                                  | the file handle is closed             |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  2 | __Chunks__           | "Data.Text"                      | `Text` is a chunk of characters       |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Text.IO"                   | Reading and writing files using       |
    |    |                      |                                  | `Text` instead of `String`            |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  3 | __Bytes__            | "Data.Word"                      | What a byte is                        |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.ByteString"                | `ByteString` is a chunk of bytes      |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Text.Encoding"             | Conversions between `ByteString`      |
    |    |                      |                                  | and `Text`                            |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.String"                    | How `ByteString` works with           |
    |    |                      +----------------------------------+ `OverloadedStrings`                   |
    |    |                      | "Data.ByteString.Char8"          |                                       |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "System.IO"                      | Putting `Handle`s into binary mode    |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  4 | __Sockets__          | "Network.Socket"                 | Opening and closing sockets           |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Network.Socket.ByteString"      | Writing to and reading from sockets   |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "System.Timeout"                 | Giving up quickly when a service      |
    |    |                      |                                  | does not respond                      |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  5 | __HTTP__             | "ASCII"                          | Expressing HTTP messages as strings   |
    |    |                      +----------------------------------+                                       |
    |    |                      | "ASCII.Char"                     |                                       |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "SocketsAndPipes.Serve"          | Our first rudimentary web server      |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  6 | __HTTP types__       | "Data.ByteString"                | Defining datatypes for the            |
    |    |                      +----------------------------------+ parts of an HTTP message              |
    |    |                      | "Data.ByteString.Lazy"           |                                       |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  7 | __Encoding__         | "Data.Text.Lazy"                 | Efficient string concatenations       |
    |    |                      +----------------------------------+                                       |
    |    |                      | "Data.Text.Lazy.Builder"         |                                       |
    |    |                      +----------------------------------+                                       |
    |    |                      | "Data.ByteString.Builder"        |                                       |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Time"                      | Simple performance testing            |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Foldable"                  | Encoding repetitions with `foldMap`   |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  8 | __Responding__       | "Network.Socket.ByteString.Lazy" | Sending responses constructed by      |
    |    |                      |                                  | bytestring `Builder`                  |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "SocketsAndPipes.Serve"          | New web server using the              |
    |    |                      |                                  | encoding functions                    |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Int"                       | Contrasting `Integer`, `Int`,         |
    |    |                      |                                  | and `Int64`                           |
    +----+----------------------+----------------------------------+---------------------------------------+
    |  9 | __Content types__    | "Data.Text.Lazy.Builder.Int"     | Building a text response body         |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Text.Blaze.Html"                | Building an HTML response body        |
    |    |                      +----------------------------------+                                       |
    |    |                      | "Text.Blaze.Html5"               |                                       |
    |    |                      +----------------------------------+                                       |
    |    |                      | "Text.Blaze.Html.Renderer.Utf8"  |                                       |
    |    |                      +----------------------------------+---------------------------------------+
    |    |                      | "Data.Aeson"                     | Building a JSON response body         |
    +----+----------------------+----------------------------------+---------------------------------------+
    | 10 | __Change__           | "Control.Concurrent.STM.TVar"    | Shared state for request-handling     |
    |    |                      +----------------------------------+ threads                               |
    |    |                      | "Control.Monad.STM"              |                                       |
    +----+----------------------+--------------------------------+-----------------------------------------+
    | 11 | __Chunked bodies__   |                                                                          |
    +----+----------------------+                                                                          |
    | 12 | __Request parsing__  |                                                                          |
    +----+----------------------+                                                                          |
    | 13 | __Reading headers__  |                                                                          |
    +----+----------------------+                 The remaining chapters are in progress.                  |
    | 14 | __Body parsing__     |                                                                          |
    +----+----------------------+                                                                          |
    | 15 | __Connection reuse__ |                                                                          |
    +----+----------------------+                                                                          |
    | 16 | __Pipes__            |                                                                          |
    +----+----------------------+--------------------------------------------------------------------------+
    .
    == Libraries
    .
    Re-exported modules, grouped by the package that each module originally comes from:
    .
    __ascii__ - "ASCII", "ASCII.Char"
    .
    __aeson__ - "Data.Aeson"
    .
    __async__ - "Control.Concurrent.Async"
    .
    __base__
    .
        * File handles - "System.IO"
        * Fundamental data types - "Data.Word", "Data.Int", "Data.Char"
        * Miscellania - "System.Timeout", "Control.Monad",
              "Data.Foldable", "Data.List"
    .
    __blaze-html__ - "Text.Blaze.Html", "Text.Blaze.Html5",
          "Text.Blaze.Html5.Attributes", "Text.Blaze.Html.Renderer.Utf8"
    .
    __bytestring__
    .
        * Strict - "Data.ByteString"
        * Lazy - "Data.ByteString.Lazy"
        * Builder - "Data.ByteString.Builder"
        * "Data.ByteString.Char8" -
            This is included mostly to discuss why we don't use it.
    .
    __network__
    .
        * "Network.Socket" -
            The Socket type, operations for opening and closing sockets
        * "Network.Socket.ByteString" -
            Socket read/write operations with strict byte strings
        * "Network.Socket.ByteString.Lazy" -
            Socket read/write operations with lazy byte strings
    .
    __safe-exceptions__ - "Control.Exception.Safe"
    .
    __stm__ - "Control.Monad.STM", "Control.Concurrent.STM.TVar"
    .
    __text__
    .
        * Strict - "Data.Text", "Data.Text.Encoding", "Data.Text.IO"
        * Lazy - "Data.Text.Lazy", "Data.Text.Lazy.Encoding", "Data.Text.Lazy.IO"
        * Builder - "Data.Text.Lazy.Builder", "Data.Text.Lazy.Builder.Int"
    .
    __time__ - "Data.Time"

source-repository head
    type:     git
    location: git://github.com/joyofhaskell/sockets-and-pipes.git

library
    default-language: Haskell2010
    default-extensions: GADTs, NamedFieldPuns, NumericUnderscores
    ghc-options: -Wall
    hs-source-dirs: src

    exposed-modules: SocketsAndPipes.Serve
    other-modules:
        SocketsAndPipes.Serve.Setup
        SocketsAndPipes.Serve.Loop
        SocketsAndPipes.Serve.Sockets
        SocketsAndPipes.Serve.ForkBracket
        SocketsAndPipes.Serve.Exceptions

    build-depends: ascii ^>= 1.0
    reexported-modules: ASCII, ASCII.Char

    build-depends: aeson ^>= 1.3 || ^>= 1.4 || ^>= 1.5
    reexported-modules: Data.Aeson

    build-depends: async ^>= 2.2
    reexported-modules: Control.Concurrent.Async

    build-depends: base ^>= 4.12 || ^>= 4.13 || ^>= 4.14
        --
        -- Update to 4.15 is held back by:
        --
        --   * network-3.1.2 introduced a dependency on the 'directory'
        --     package, which does not yet support base-4.15.
        --
    reexported-modules:
        Control.Monad,
        Data.Char,
        Data.Foldable,
        Data.Int,
        Data.List,
        Data.Word,
        System.IO,
        System.Timeout

    build-depends: blaze-html ^>= 0.9
    reexported-modules:
        Text.Blaze.Html,
        Text.Blaze.Html5,
        Text.Blaze.Html5.Attributes,
        Text.Blaze.Html.Renderer.Utf8

    build-depends: bytestring ^>= 0.10
        --
        -- Update to 0.11 is held back by:
        --
        --   * https://github.com/jaspervdj/blaze-html/issues/135
        --
    reexported-modules:
        Data.ByteString,
        Data.ByteString.Builder,
        Data.ByteString.Char8,
        Data.ByteString.Lazy

    build-depends: containers ^>= 0.5.7 || ^>= 0.6

    build-depends: network ^>= 3.1.2
        --
        -- Reasons for lower bounds:
        --
        --   * 3.1.1 introduced the 'gracefulClose' function.
        --   * 3.1.1 series is deprecated due to flaw in 'gracefulClose'.
        --   * 3.1.2 introduced the 'openSocket' function.
        --
    reexported-modules:
        Network.Socket,
        Network.Socket.ByteString,
        Network.Socket.ByteString.Lazy

    build-depends: safe-exceptions ^>= 0.1
    reexported-modules: Control.Exception.Safe

    build-depends: stm ^>= 2.5
    reexported-modules:
        Control.Concurrent.STM,
        Control.Concurrent.STM.TVar,
        Control.Monad.STM

    build-depends: text ^>= 1.2.3
        --
        -- Reasons for lower bounds:
        --
        --   * 1.2.3 is the first version that works with base-4.12.
        --
    reexported-modules:
        Data.Text,
        Data.Text.Encoding,
        Data.Text.Lazy,
        Data.Text.Lazy.Builder,
        Data.Text.Lazy.Builder.Int,
        Data.Text.Lazy.Encoding,
        Data.Text.Lazy.IO,
        Data.Text.IO

    build-depends: time ^>= 1.9 || ^>= 1.10
        --
        -- Update to 1.11 is held back by:
        --
        --   * https://github.com/haskell/directory/issues/115
        --
    reexported-modules: Data.Time