Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharkdp/purescript-sparkle
Infer user interfaces from type signatures
https://github.com/sharkdp/purescript-sparkle
purescript testing
Last synced: 10 days ago
JSON representation
Infer user interfaces from type signatures
- Host: GitHub
- URL: https://github.com/sharkdp/purescript-sparkle
- Owner: sharkdp
- Created: 2016-01-02T20:06:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-30T20:15:32.000Z (almost 7 years ago)
- Last Synced: 2025-01-11T17:13:13.026Z (12 days ago)
- Topics: purescript, testing
- Language: PureScript
- Homepage: http://sharkdp.github.io/purescript-sparkle/
- Size: 216 KB
- Stars: 78
- Watchers: 7
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Automatically create reactive web interfaces from type signatures.
Live demo and tutorial
| Conference talk
| Try in your browser
| Documentation
Sparkle is a library that leverages the power of [PureScripts](http://purescript.org) type system to automatically create user interfaces based on type signatures.
The internal mechanism of this library is similar to [QuickCheck](https://github.com/purescript/purescript-quickcheck). However, instead of using randomly generated input data, Sparkle creates reactive web interfaces for "interactive testing". It uses the [Flare library](https://github.com/sharkdp/purescript-flare) to create those widgets.
## Example
Consider the following (hypothetic) function:
``` purs
formatNumber :: Number -> Int -> Char -> Boolean -> String
formatNumber value precision decimalMark isSigned = ...
```
Sparkle can automatically create a user interface for `formatNumber` by simply calling:
``` purs
sparkle "formatNumber" formatNumber
```
The result looks like this:![Sparkle widget](https://i.imgur.com/xB13OGZ.png)
Notice how each input type (`Number`, `Int`, `Char`, `Boolean`) is represented by an appropriate input field.
Check out the **[demo page](http://sharkdp.github.io/purescript-sparkle/)** for an interactive version.## Quick start
- Start a PureScript project in a new folder:
```
pulp init
```- Install *Sparkle*:
```
bower install --save purescript-sparkle
```- Write your own code (`src/MyModule.purs`), for example:
``` purs
module MyModule (substring) whereimport Prelude
import Data.Stringsubstring :: Int -> Int -> String -> String
substring start end str = take (end - start) (drop start str)
```- Write the module that creates the interactive Sparkle tests (`test/Main.purs`):
``` purs
module Test.Main whereimport Prelude
import MyModule
import Sparklemain = sparkle "substring" substring
```- Compile and bundle:
```
pulp build -O -I test -m Test.Main -t test.js
```- Copy the `index.html` and `sparkle.css` file from the `assets` folder:
``` bash
cp bower_components/purescript-sparkle/assets/* .
```- Open `index.html` in the browser.