streaming-bracketed: A resource management decorator for "streaming".

[ data, library, mit, streaming ] [ Propose Tags ] [ Report a vulnerability ]

This package provides a decorator for the Stream type from "streaming", that lets you perform bracket-like operations that allocate and deallocate resources used by the stream.

By carefully managing the operations that are lifted to the decorated streams, we can ensure that finalizers are promptly called even with operations like "take", which do not consume the whole stream.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0
Change log ChangeLog.md
Dependencies base (>=4.10 && <5), streaming (>=0.2.0.0 && <0.3) [details]
License MIT
Author daniel
Maintainer diaz_carrete@yahoo.com
Category Data, Streaming
Source repo head: git clone https://github.com/danidiaz/streaming-bracketed.git
Uploaded by DanielDiazCarrete at 2020-06-15T15:33:16Z
Distributions NixOS:0.1.1.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1360 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-06-15 [all 1 reports]

Readme for streaming-bracketed-0.1.1.0

[back to package description]

streaming-bracketed

Build Status

What's this?

A resource management "decorator" for the Stream type from streaming.

The idea is that the Bracketed type represents a Stream which might have some finalizers that will be triggered when we reach a given point in the stream.

By being careful about how we lift operations to work on Bracketed streams, we can ensure that finalizers are promptly called even with operations like take.

Bracketed streams are ultimately consumed by using a continuation.

Differences with resourcet

resourcet is a widely used library for resource handling. It provides a monad transformer over IO that keeps track of registered resources and ensures proper cleanup.

The main differences with the present library are:

  • This library only works on Streams from streaming.

  • Bracketed sits above the streaming monad, not below like ResourceT.

  • This library aims to provide smarter handling of stream functions like take, without too much hassle.

  • In this library finalizer scopes are nested, unlike ResourceT which allows arbitrary interleavings.

Doubts

  • Lifting functions like splitAt might cause problems if we try to use the rest of the stream.

Motivation

From the CHANGELOG of the streaming package:

Remove bracketStream, MonadCatch instance, and everything dealing with
ResourceT. All of these things of sort of broken for Stream since there is no
guarantee of linear consumption (functions like take can prevent finalizers
from running).

One Github issue.

Another one.

Streaming libs exercise/challenge:

Given a list [(Filepath,Int,Int)] of files and line ranges, create a stream
of lines belonging to the concatenated ranges.

Prompt release of file handles is required. resource-handling monads and
"withXXX"-style functions are allowed.