Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created October 14, 2014 17:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Raynos/981e8f8d0e1d069e5590 to your computer and use it in GitHub Desktop.
Save Raynos/981e8f8d0e1d069e5590 to your computer and use it in GitHub Desktop.

What is an FRP application.

An FRP application has the following properties

  • Functional, pure, immutable.
  • Reactive, your application is a DAG, you react to "core" inputs and from new outputs.

Being an immutable DAG

If your application is an immutable DAG it has certain properties

  • Each conceptual node in the DAG is the sole owner of truth for that information.
  • A DAG can be serialized, have time rewound on it, can go through an interactive debugger, etc.
  • Parts of your application only change by reacting to input, you know exactly what can cause state changes in any part of your application by looking at which inputs you react to.

Purity and the DAG

The meat of your application, inputs, update, state and render is pure. This means it consists of plain functions that do not do IO nor have effects.

The actual IO or effectful part of your application is completely at the edges of your DAG. This means you can easily test your application because it's just logic. You can easily run your application in a web worker because it's just logic. You can easily do introspection on your application or time rewinding because doing so has no effects.

Removing implementation complexity.

When building GUI progress with a DAG you can take "raw" input from various sources (events, mouse, keyboard) and convert them into actual logical, well typed "user intents" that are agnostic of the implementation details of your host environment. The same applies for output, you can create a well typed structural representation of your UI and have it be rendered in the host environment.

You get to choose what type of structural representation you want for the visual UI and you get to choose what kind of user intents you want to operate upon. Your application is shielded from the implementation details of the Host environment and they do not corrupt their way into your application.

@staltz
Copy link

staltz commented Oct 14, 2014

PS: I know that in this intro I said Rx was FRP, but later I learned my lesson that it isn't. I still find it hard to categorize Elm's and Rx's similarities, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment