Personal tools


From HaskellWiki

Revision as of 15:17, 1 December 2011 by Ertes (Talk | contribs)

Jump to: navigation, search

Netwire is a library for functional reactive programming, which uses the concept of arrows for modelling an embedded domain-specific language. This language lets you express reactive systems, which means systems that change over time. It shares the basic concept with Yampa and its fork Animas, but it is itself not a fork and has many additional features.

This wiki page corresponds to Netwire version 3 and is currently a work in progress.

1 Features

Here is a list of some of the features of Netwire:

  • arrow interface (or optionally an applicative interface),
  • signal inhibition (ArrowZero / Alternative),
  • signal selection (ArrowPlus / Alternative),
  • self-adjusting wires (ArrowChoice),
  • rich set of event wires,
  • signal analysis wires (average, peak, etc.),
  • effectful wires.

2 Basics

The Netwire library is based around a data type called
data Wire e (>~) a b
For some arrows
and all monoids
the type
Wire e (>~)
is an arrow. Only certain arrows are allowed for
, because Wire is actually a data family. These arrows are called base arrows in Netwire.
comp :: Wire e (>~) a b
Values of type
Wire e (>~) a b
are time-varying functions, which resemble the following type:
a >~ Either e b
So it's a function that takes a value of type
and either produces a value of type
or produces no value, but instead inhibits with a value of type
. The act of running a wire is called stepping and the process is called an instant. You can step a wire through one of the stepping functions, which we will cover later. When you step a wire, it will return a new version of itself along with its result. You are supposed to call the new version the next time you step.

=== Base arrows

argument to
is called the base arrow.