MyNixOS website logo
Description

Applicative/Arrow for resource estimation and progress tracking.

This module contains a writer-like Applicative for giving monoidal annotations to underlying computations. The annotations are available before running the computations. It also allows tagging different parts of a computation as separate steps, so that progress notifications can be emitted during execution. Optional steps are allowed.

plan-applicative

A writer-like Applicative/Arrow for resource estimation and progress tracking.

Motivation

I run scripts in my machine. Their logic is simple and predictable, even if the steps are many and take long to complete.

The following infuriating situations happen:

  • The script fails at minute 45 because of a syntax error.
  • The script fails at minute 45 because it requests a missing resource whose availability could have been checked when the script started.
  • It is difficult to ascertain how far along the execution we are at minute 45.

The first problem is solved by using a statically typed language or, for dynamic languages, some kind of staticanalysis tool.

For the second problem, we need to have a summary of the resources that the computation will require, before running the computation itself. This can be done by hand, adding a new check at the beginning of the script when we change something further down. But it's easy to forget to do so, and the initial checks can become out of sync with the main code. It would be nice if each step of the computation foresaw its own resource needs and these accumulated automatically as we composed the steps.

For the third problem, we need a channel that notifies you whenever a step of the computation starts or finishes. Bonus points if nested steps are supported.

Problems

Currently the ApplicativeDo extension doesn't work very well with this package's Applicative because an extant bug in GHC: #10892. Sequencing actions whose values are ignored gives an error.

Inspiration

  • StaticArrow from the arrows package.

  • Not exactly an inspiration (as I don't understand the stuff well enough) but Tomas Petricek's work on "coeffects" seems relevant for helping applications to "fail early". See section 1.1 of his thesis.

Metadata

Version

2.0.1.0

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