HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleservant-0.20.2Haskell2010

Servant.API.Stream

  • 9 types
  • 5 classes
  • Packageservant-0.20.2
  • Exports14
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceStream.hs
datadata Stream (method :: k1) (status :: Nat) framing contentType a
#

A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Type synonyms are provided for standard methods.

Instances4HasLink, Generic, Rep, MkLink
  • HasLink (Stream m status fr ct a)Defined in servant-0.20.2 · Servant.Links
  • Generic (Stream method status framing contentType a)Defined in servant-0.20.2 · Servant.API.Stream
  • type Rep (Stream method status framing contentType a) = D1 ('MetaData "Stream" "Servant.API.Stream" "servant-0.20.2-kmMZib8zXn7e8NZPkSX15" 'False) V1Defined in servant-0.20.2 · Servant.API.Stream
  • type MkLink (Stream m status fr ct a) r = rDefined in servant-0.20.2 · Servant.Links
datadata StreamBody' (mods :: [Type]) framing contentType a
#
Instances4HasLink, Generic, Rep, MkLink

Source

3 declarations

SourceIO are equivalent to some *source* in streaming libraries.

typetype SourceIO = SourceT IO
#

Stream endpoints may be implemented as producing a SourceIO chunk.

Clients reading from streaming endpoints can be implemented as consuming a SourceIO chunk.

classclass ToSourceIO chunk a | a -> chunk where
#

ToSourceIO is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly as endpoints.

Methods

Instances3ToSourceIO
classclass FromSourceIO chunk a | a -> chunk where
#

FromSourceIO is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly on the client side for talking to streaming endpoints.

Methods

Instances1FromSourceIO

Auxiliary classes

Framing

2 declarations
classclass FramingRender (strategy :: k) where
#

The FramingRender class provides the logic for emitting a framing strategy. The strategy transforms a SourceT m a into SourceT m ByteString, therefore it can prepend, append and intercalate framing structure around chunks.

Note: as the Monad m is generic, this is pure transformation.

Methods

Instances3FramingRender
classclass FramingUnrender (strategy :: k) where
#

The FramingUnrender class provides the logic for parsing a framing strategy.

Methods

Instances3FramingUnrender

Strategies

datadata NoFraming
#

A framing strategy that does not do any framing at all, it just passes the input data This will be used most of the time with binary data, such as files

Instances2FramingRender, FramingUnrender
  • FramingRender NoFramingDefined in servant-0.20.2 · Servant.API.Stream
  • FramingUnrender NoFramingDefined in servant-0.20.2 · Servant.API.Stream

    As NoFraming doesn't have frame separators, we take the chunks as given and try to convert them one by one.

    That works well when a is a ByteString.

datadata NewlineFraming
#

A simple framing strategy that has no header, and inserts a newline character after each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).

Instances2FramingRender, FramingUnrender
datadata NetstringFraming
#

The netstring framing strategy as defined by djb: http://cr.yp.to/proto/netstrings.txt

Any string of 8-bit bytes may be encoded as [len]":"[string]",". Here [string] is the string and [len] is a nonempty sequence of ASCII digits giving the length of [string] in decimal. The ASCII digits are 30 for 0, 31 for 1, and so on up through 39 for 9. Extra zeros at the front of [len] are prohibited: [len] begins with 30 exactly when [string] is empty.

For example, the string "hello world!" is encoded as 32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c, i.e., "12:hello world!,". The empty string is encoded as "0:,".

Instances2FramingRender, FramingUnrender