From c78586511f6440b5892772abaa22a980b304003c Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Sun, 6 Aug 2017 15:18:48 -0700 Subject: [PATCH] Server setup for behaviors --- .gitignore | 1 + staging/behaviors/psc-package.json | 10 ++++++++++ staging/behaviors/src/FRP/Try.purs | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 staging/behaviors/psc-package.json create mode 100644 staging/behaviors/src/FRP/Try.purs diff --git a/.gitignore b/.gitignore index 1e60e0ba..884a06b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.psc-ide-port .pulp-cache/ .psci_modules/ .stack-work/ diff --git a/staging/behaviors/psc-package.json b/staging/behaviors/psc-package.json new file mode 100644 index 00000000..12d77691 --- /dev/null +++ b/staging/behaviors/psc-package.json @@ -0,0 +1,10 @@ +{ + "name": "trybehaviors", + "set": "master", + "source": "https://github.com/purescript/package-sets.git", + "depends": [ + "drawing", + "behaviors", + "prelude" + ] +} \ No newline at end of file diff --git a/staging/behaviors/src/FRP/Try.purs b/staging/behaviors/src/FRP/Try.purs new file mode 100644 index 00000000..62544264 --- /dev/null +++ b/staging/behaviors/src/FRP/Try.purs @@ -0,0 +1,17 @@ +module FRP.Try (defaultMain) where + +import Prelude + +import Control.Monad.Eff (Eff) +import Data.Foldable (for_) +import FRP (FRP) +import FRP.Behavior (Behavior, animate) +import Graphics.Canvas (CANVAS, getCanvasElementById, getContext2D) +import Graphics.Drawing (Drawing, render) + +defaultMain :: Behavior Drawing -> Eff (canvas :: CANVAS, frp :: FRP) Unit +defaultMain b = do + canvas <- getCanvasElementById "canvas" + for_ canvas \c -> do + ctx <- getContext2D c + animate b (render ctx)