Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bodil/purescript-signal
Elm style FRP library for PureScript
https://github.com/bodil/purescript-signal
Last synced: 24 days ago
JSON representation
Elm style FRP library for PureScript
- Host: GitHub
- URL: https://github.com/bodil/purescript-signal
- Owner: bodil
- License: apache-2.0
- Created: 2014-09-19T20:27:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-30T07:51:12.000Z (over 2 years ago)
- Last Synced: 2024-10-01T04:24:22.590Z (about 1 month ago)
- Language: PureScript
- Size: 242 KB
- Stars: 259
- Watchers: 14
- Forks: 44
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-purescript - purescript-signal
- awesome-purescript - purescript-signal - An asynchronous signal library for PureScript, similar to Elm. (Asynchronicity and Parallelism)
README
# purescript-signal
[![Build Status](https://travis-ci.org/bodil/purescript-signal.svg?branch=master)](https://travis-ci.org/bodil/purescript-signal)
Signal is a lightweight FRP-like library heavily inspired by the Elm Signal implementation. Where possible and sensible, it tries to maintain API equivalence with Elm.
See [the Elm documentation](http://elm-lang.org:1234/guide/reactivity#signals) for details on usage and principles.
## PureScript Usage Patterns
PureScript depends on effects (specifically, the `Effect` monad) to manage side effects, where Elm's runtime generally manages them for you. `purescript-signal` provides the `Signal.runSignal` function for running effectful signals.
```purescript
module Main whereimport Effect.Console
import Effect (Effect)
import Prelude
import Signalhello :: Signal String
hello = constant "Hello Joe!"helloEffect :: Signal (Effect Unit)
helloEffect = hello ~> logmain = runSignal helloEffect
```This simple example takes a constant signal which contains the string `"Hello Joe!"` and maps it over the `Effect.Console.log` function, which has the type `String -> Effect Unit`, thus taking the `String` content of the signal and turning it into an effect which logs the provided string to the user's console.
This gives us a `Signal (Effect Unit)`. We use `runSignal` to take the signal of effects and run each effect in turn—in our case, just the one effect which prints `"Hello Joe!"` to the console.
## API Documentation
* [Module documentation on Pursuit](https://pursuit.purescript.org/packages/purescript-signal/)
## Usage Examples
* The canonical Elm Mario: https://github.com/michaelficarra/purescript-demo-mario
* Ponies: https://github.com/bodil/purescript-is-magic