Apache-2.0 licensed by Cardano Foundation (High Assurance Lab)
Maintained by [email protected]
This version can be pinned in stack with:delta-types-1.0.0.0@sha256:3e3abeb8e4011c58f75a905150f6b1d5286add40faf007b2ed9f2cdf9b7eef42,2574

Overview

This package provides a notion of delta types via the Delta typeclass.

A delta type da for a base type a is a collection of values that each correspond to a change a → a of the base type. The following typeclass captures this correspondence:

class Delta da where
    type Base da = a
    apply :: da → (a → a)

In the literature, this concept is also known as a change action, with relations to incremental computation and differential lambda calculus. See References.

For example, one delta type for Set a is given by

data DeltaSet1 a = Insert a | Delete a

instance Delta (DeltaSet1 a) where
    type Base (DeltaSet1 a) = Set a
    apply (Insert a) = Data.Set.insert a
    apply (Delete a) = Date.Set.delete a

In general, there may be multiple delta types associated with a single base type.

References

  1. Alvarez-Picallo, M., Eyers-Taylor, A., Peyton Jones, M., Ong, CH.L. (2019). Fixing Incremental Computation. In: Caires, L. (eds) Programming Languages and Systems. ESOP 2019. Lecture Notes in Computer Science(), vol 11423. Springer, Cham.
  2. M. Alvarez-Picallo, M. (2020). Change actions: from incremental computation to discrete derivatives. PhD thesis, Oxford.
  3. Apfelmus, H. (2023). Delta encodings help separate business logic from database operations. Bobkonf 2023, Berlin.

Changes

Revision history for delta-types

1.0.0.0 — 2025-02-26

  • Initial version