Module

Data.Incremental

Package
purescript-incremental-functions
Repository
paf31/purescript-incremental-functions

Incremental computation, based on

"A Theory of Changes for Higher-Order Languages" by Cai, Giarrusso, Rendel and Ostermann.

This module also defines a HOAS-style interface for working with function changes.

#Patch Source

class (Monoid d) <= Patch a d | a -> d where

The monoid d of changes acts on values of type a.

Members

Instances

#Diff Source

class (Patch a d) <= Diff a d | a -> d where

Members

Instances

#Change Source

data Change a

A type level function which maps a type to the type of its change structure.

Uniqueness of instances makes the coercions fromChange and toChange safe, since the functional dependency makes the change structure type unique.

Instances

#fromChange Source

fromChange :: forall da a. Patch a da => Change a -> da

#toChange Source

toChange :: forall da a. Patch a da => da -> Change a

#Jet Source

type Jet a = { position :: a, velocity :: Change a }

A value (position) paired with a change (velocity).

We can think of these modified terms as conceptually similar to dual numbers.

We can use functions of type Jet a -> Jet b as incremental functions from a to b, which gives us a HOAS-style DSL for working with jets.

#constant Source

constant :: forall da a. Patch a da => a -> Jet a

A constant term

#change Source

change :: forall da a. Patch a da => Change a -> Jet a -> Jet a

Create a function which applies a patch to its input