@hackage sockets-and-pipes0.1

Support for the Sockets and Pipes book

This package contains some utilities that support Sockets and Pipes (available on 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:

ChapterModulePurpose
1 Handles System.IOWriting to a file
Control.Exception.Safe Using bracket to ensure the file handle is closed
2 Chunks Data.TextText is a chunk of characters
Data.Text.IO Reading and writing files using Text instead of String
3 Bytes Data.WordWhat a byte is
Data.ByteStringByteString is a chunk of bytes
Data.Text.Encoding Conversions between ByteString and Text
Data.StringHow ByteString works with OverloadedStrings
Data.ByteString.Char8
System.IOPutting Handles into binary mode
4 Sockets Network.SocketOpening and closing sockets
Network.Socket.ByteStringWriting to and reading from sockets
System.Timeout Giving up quickly when a service does not respond
5 HTTP ASCIIExpressing HTTP messages as strings
ASCII.Char
SocketsAndPipes.ServeOur first rudimentary web server
6 HTTP types Data.ByteStringDefining datatypes for the parts of an HTTP message
Data.ByteString.Lazy
7 Encoding Data.Text.LazyEfficient string concatenations
Data.Text.Lazy.Builder
Data.ByteString.Builder
Data.TimeSimple performance testing
Data.FoldableEncoding 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.IntBuilding a text response body
Text.Blaze.HtmlBuilding an HTML response body
Text.Blaze.Html5
Text.Blaze.Html.Renderer.Utf8
Data.AesonBuilding a JSON response body
10 Change Control.Concurrent.STM.TVarShared state for request-handling threads
Control.Monad.STM
11Streaming The remaining chapters are in progress.
12Request parsing
13Reading headers
14Body parsing
15Connection reuse
16Pipes

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