Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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 callgebra
const {chain} = require ('callgebra')
import {chain} from 'callgebra/index.js'

API

type Callback a b = (b -> a) -> a

of :: 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.

You can’t perform that action at this time.