Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

paf31/purescript-behaviors-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-behaviors-demo

purescript-behaviors demo in the REPL

Guide

First install dependencies:

npm install -g purescript pulp bower
bower update

Then open the REPL:

$ pulp psci -- --port 8080

Navigate to http://localhost:8080/.

Mouse Position

Follow the cursor:

> live $ map (\{ x, y } -> dot x y 50.0) mouse

Mouse Clicks

Increase the radius when the mouse is clicked:

> withRadius radius = live $ (\{ x, y } r -> dot x y r) <$> mouse <*> radius
> withRadius $ map (if _ then 100.0 else 50.0) click

Functions of Time

Express the radius as an integral over time:

> withRadius $ integral' 50.0 seconds (map (if _ then 50.0 else 0.0) click)

Advanced Functions of Time

Express the radius as a solution of a differential equation:

> :paste
… withRadius $ 
    fixB 50.0 \x ->  
      integral' 50.0 seconds $  
        integral' 0.0 seconds $  
          (\y dy -> if _ then 100.0 else -5.0 * (y - 50.0) - 2.0 * dy)  
          <$> x  
          <*> derivative' seconds x  
          <*> click 

About

purescript-behaviors in PSCi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published