Callgebra
The little algebra of callbacks.
Introduction
This package exports functions for composing callbacks. You can read about the idea in my Medium post about composable callbacks.
Usage
$ npm install callgebraconst {chain} = require ('callgebra')import {chain} from 'callgebra/index.js'API
type Callback a b = (b -> a) -> aof :: a -> Callback b a
Creates a callback for a given return value.
chain :: (a -> Callback c b) -> Callback c a -> Callback c b
Sequence two callback-accepting functions.
map :: (a -> b) -> Callback c a -> Callback c b
Modify the return value of a callback.
ap :: Callback c (a -> b) -> Callback c a -> Callback c b
Apply the function returned by one callback to the value returned by another.
callback :: (a -> b) -> Callback b a -> b
Given a function and a Callback, runs the Callback using the function.