@hackage valiant-streamly0.1.0.0

Streamly streaming adapter for valiant

  • Installation

  • Tested Compilers

  • Dependencies (3)

  • Dependents (0)

  • Package Flags

      werror
       (off by default)

      Enable -Werror for development builds.

valiant-streamly

Streamly adapter for valiant.

Produces Stream IO r values from query results.

Quick start

import Valiant
import Valiant.Streamly
import Streamly.Data.Stream qualified as Stream
import Streamly.Data.Fold qualified as Fold

countUsers :: Pool -> IO Int
countUsers pool =
  withTransaction pool $ \tx ->
    Stream.fold Fold.length $
      selectStreamly (txConn tx) listAllUsers () 500

Two streaming strategies

  • selectStreamly conn stmt params batchSize — cursor-based. Must run inside a transaction.
  • foldStreamly conn stmt params — single-shot extended-protocol query. No transaction required.

Both functions accumulate one result set at a time before yielding. For truly incremental memory use, drive Valiant.withCursor / Valiant.fetchBatch directly.

See the valiant tutorial for Statement definitions and the valiant prepare workflow.