MyNixOS website logo
Description

A resource management decorator for "streaming"

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.

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.
Metadata

Version

0.1.1.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows