Package

purescript-hareactive

Repository
funkia/purescript-hareactive
License
MIT
Uploaded by
paldepind
Published on
2019-07-29T12:00:16Z

Hareactive on Pursuit Build status

Hareactive is a practical, powerful, and simple FRP library.

Highlights

  • Implements classic FRP with behaviors and streams.
  • Supports continuous time and integration.
  • Higher-order monadic behaviors.
  • Efficient push and pull implementation.
  • Simple precise semantics.
  • Supports circular dependencies i.e. recursively defined behaviors.
  • Easy integration with both Effect and Aff for side-effects.
  • Suitable for building UI (see also purescript-turbine).

Examples

Counter

single counter GIF

A simple example which show how to create a counter with FRP and demonstrates how to integrate Hareactive with the DOM. Source code.

Background

Hareactive is highly inspired by the papers Push-Pull Functional Reactive Programming by Conal Elliott and Practical principled FPP by Atze van der Ploeg and Koen Claessen.

Hareactive implements classic FRP. This means that it makes a distinction between behaviors and streams (what Hareactive calls streams is often called event). As for why that distinction is useful see the blogpost Behaviors and streams, why both?.

Behaviors in Hareactive are monads. Monadic behaviors are essential for many practical purposes. Behaviors in Hareactive can be continuous, i.e. change infinetly often. Among other things this means that Hareactive support continous time and integration.

Hareactive supports stateful behaviors (i.e. behaviors that depends on the past). It does so while avoiding the problems with space and time leaks that FRP are notorius for.

A key focus is to implement a simple precise semantic model following in the spirit of Conal Elliott. The semantics serve as a specification for determining the correctness of the implementation. Additionally, it is a mental model which can be used to reason about the library.

Hareactive is implemented in carefully optimized TypeScript.

Install

npm i @funkia/hareactive
bower install --save purescript-hareactive

Documentation

Module documentation is published on Pursuit.