• This repository has been archived on 02/Feb/2021
  • Stars
    star
    134
  • Rank 269,930 (Top 6 %)
  • Language PureScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple push-pull FRP implementation

purescript-behaviors

Example

Building

pulp build
npm run example

Introduction

Push-pull FRP is concerned with events and behaviors. Events are values which occur discretely over time, and behaviors act like continuous functions of time.

Why bother with behaviors at all, when the machines we work with deal with events such as interrupts at the most basic level?

Well, we can work with continuous functions of time in a variety of ways, including by differentiation and integration. Also, working with a conceptually infinitely-dense representation means that we can defer the choice of sampling interval until we are ready to render our results.

This library takes a slightly novel approach by constructing behaviors from events.

newtype ABehavior event a = ABehavior (forall b. event (a -> b) -> event b)

type Behavior = ABehavior Event

Here, a Behavior is constructed directly from its sampling function. The various functions which work with this representation can delay the choice of sampling interval for as long as possible, but ultimately this Behavior is equivalent to working with events directly, albeit with alternative, function-like instances.

This representation has the correct type class instances, and supports operations such as integration, differentiation and even recursion, which means we can use it to solve interactive differential equations. For example, here is an exponential function computed as the solution of a differential equation:

exp = fixB 1.0 \b -> integral' 1.0 seconds ((-2.0 * _) <$> b)

Its differential equation is 𝑑π‘₯/𝑑𝑑 = βˆ’2π‘₯ , which is rearranged so the right hand side gives an expression whose fixed point solution is the exponential function desired.

π‘₯ = βˆ«βˆ’2π‘₯ 𝑑𝑑

(In the purescript formulation, the values 1.0 are respectively the initial value for the Behavior being integrated over, and the initial approximation to the integral)

See the example project for a more interesting, interactive example.

See also a conversational demo. An accompanying video discussion breaks down a component of the example project.

More Repositories

1

purescript-book

Sources for the PureScript book
PureScript
454
star
2

purescript-thermite

A simple PureScript wrapper for React
PureScript
350
star
3

24-days-of-purescript-2016

24 Days of PureScript, 2016
287
star
4

initialround

Web app for interviewing technical candidates in the browser
C#
163
star
5

purescript-sdom

An experiment in replacing the virtual DOM and avoiding diffing
PureScript
161
star
6

dovetail

A PureScript interpreter in Haskell
Haskell
118
star
7

purescript-purview

A UI library based on the incremental lambda calculus
PureScript
111
star
8

purescript-react-explore

Experiments with comonads for modelling React UIs
PureScript
90
star
9

purescript-incremental-functions

Incremental lambda calculus
PureScript
80
star
10

purescript-foreign-generic

Generic deriving for purescript-foreign
PureScript
63
star
11

purescript-quickserve

Quick HTTP servers
PureScript
60
star
12

haskell-slides

Haskell
50
star
13

purescript-drawing

A data structure for drawings
PureScript
47
star
14

purescript-derive-lenses

A little utility to derive lenses and prisms for data types in PureScript
PureScript
41
star
15

purescript-smash

An "extensible coeffect" system built out of comonads and Day convolution.
PureScript
36
star
16

the-future-is-comonadic

My (rejected) OBT-2018 submission
TeX
35
star
17

purescript-rest

A toolkit for creating REST services with Node and PureScript
PureScript
32
star
18

purescript-jquery

Type declarations for jQuery
PureScript
30
star
19

mu-kanren

A step-by-step MicroKanren evaluator
JavaScript
29
star
20

star-dodge-clone

A partial clone of 2D Star Dodge
PureScript
26
star
21

purescript-safely

A combinator for making any monadic control operator stack-safe
PureScript
26
star
22

24-days-of-purescript-2014

25
star
23

purescript-event

The Event type, extracted from purescript-behaviors
PureScript
23
star
24

purescript-debugger

A simple console debugger for PureScript functions
PureScript
22
star
25

purescript-graphics-vis

A library for interactively creating graphics visualizations
PureScript
22
star
26

typescript-docs

A documentation tool for TypeScript Definition files
Haskell
21
star
27

purescript-behaviors-demo

purescript-behaviors in PSCi
PureScript
19
star
28

language-typescript

Haskell library for working with TypeScript Definition files
Haskell
18
star
29

purescript-leibniz

Leibniz Equality
PureScript
18
star
30

purescript-memoize

Type classes for creating memoized functions
PureScript
18
star
31

lambdaconf-2015

Materials for my LambdaConf 2015 Workshop
PureScript
17
star
32

purescript-yargs

PureScript bindings for the yargs command-line parsing library
PureScript
17
star
33

partial

A nullary type class for partial functions
Haskell
15
star
34

purescript-signal-loop

An abstraction on top of purescript-signal, for avoiding Channels
PureScript
15
star
35

purescript-folds

Applicative Folds, in the style of Gabriel Gonzalez' foldl library
PureScript
14
star
36

purescript-free-canvas

A free monad interface to the canvas
PureScript
13
star
37

purescript-lists-fast

Fast replacements for some common functions on linked lists
PureScript
13
star
38

purescript-hooks

PureScript
12
star
39

Purity

CLR-Hosted Total Functional Programming Language
C#
11
star
40

dicom-haskell-library

A library for reading and writing DICOM files in the Explicit VR Little Endian transfer syntax.
Haskell
10
star
41

purescript-day

Day Convolution
PureScript
10
star
42

runpurs

PureScript corefn interpreter experiment for processing JSON
JavaScript
10
star
43

purescript-hoist

Optics between functors
PureScript
10
star
44

purescript-foreign-lens

A lens-compatible set of getters for purescript-foreign
PureScript
10
star
45

purescript-node-coroutines

Coroutines for working with Node streams
PureScript
9
star
46

lambdaconf

LambdaConf Notes
JavaScript
9
star
47

Embedding-a-Full-Linear-Lambda-Calculus-in-Haskell

Embedding a Full Linear Lambda Calculus in Haskell
8
star
48

Adventure

For the LA Haskell Meetup
Haskell
8
star
49

purescript-scoped-labels

A little implementation of records with duplicate labels
PureScript
8
star
50

purescript-pprint

A simple pretty printing library
PureScript
8
star
51

purescript-bsp-experiment

An isometric canvas renderer which supports transparency
JavaScript
8
star
52

purescript-lens-simple

Very basic lenses
PureScript
7
star
53

purescript-reflection

Reflecting values at the type level
PureScript
7
star
54

stack-safety-for-free

A note on the approach to stack-safety in PureScript's core libraries
PureScript
7
star
55

purescript-tropical

Tropical Semirings
PureScript
6
star
56

purescript-pairing

Pairings of functors
PureScript
6
star
57

codemesh2016

Code Mesh 2016 slides
PureScript
5
star
58

tablestorage

Azure Table Storage REST API Wrapper
Haskell
4
star
59

hasuracon-2022

Haskell
4
star
60

blog-source

Markdown files and static site generator script for my blog.
Haskell
4
star
61

purescript-distributions

A monad which generalizes the probability monad to an arbitrary Semiring of probabilities
PureScript
4
star
62

purescript-isomorphisms

A category of isomorphisms, and some standard isomorphisms
PureScript
4
star
63

HsDiff

Haskell Diff Tool
Haskell
4
star
64

tinytemplate

A tiny text templating library for Haskell
Haskell
3
star
65

purescript-webidl

A wrapper for the webidl2 library
PureScript
3
star
66

Automata-hs

A monad for finite deterministic automata
Haskell
3
star
67

purescript-with-index

A tiny library for composing indexed traversals
PureScript
3
star
68

old-blog

Very old blog posts
2
star
69

supervisor

A simple ptrace-based supervisor
C
2
star
70

BF

BF .NET Compiler
C#
2
star
71

purescript-croco

Croco Magneto remake in PureScript - work in progress
JavaScript
2
star
72

acme-all-monad

A monad which is powerful enough to interpret any action
Haskell
2
star
73

codejam

Google CodeJam Solutions
Haskell
1
star
74

purescript-sammy

PureScript bindings for Sammy.js, a Javascript, browser-based Sinatra-clone.
PureScript
1
star
75

parsel

A just-in-time compiler for recursive descent parsers
C#
1
star
76

paf31.github.io

functorial
HTML
1
star
77

with-index

A tiny library for composing indexed traversals
Haskell
1
star
78

purescript-taylor

Taylor series
PureScript
1
star
79

purescript-drumloops

Experimenting with purescript-howler
PureScript
1
star
80

Automata

A monad for finite deterministic automata
C#
1
star
81

pattern-arrows

Arrows for Pretty Printing
Haskell
1
star
82

monad-unify

A library for type-safe first-order unification
Haskell
1
star
83

purescript-handlebars

Simple bindings to the handlebars text templating library
PureScript
1
star