From f2ecb4950c49d4c1e933d5ab47cfca9b5f664b31 Mon Sep 17 00:00:00 2001 From: Dierk Koenig Date: Thu, 13 Aug 2015 16:36:32 +0200 Subject: [PATCH] make the interaction even more "play"ful --- Stairs.fr | 9 +++++++-- client/src/main/frege/org/frege/Application.fr | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Stairs.fr b/Stairs.fr index e59ee8a..f71d293 100644 --- a/Stairs.fr +++ b/Stairs.fr @@ -34,10 +34,15 @@ connect ctx (nextHead,head,_,_) = withUI $ ctx.strokeLine head.x head.y nextHead doodle :: GraphicsContext -> [IO ()] doodle ctx = map (connect ctx) trails +--- Play any function _f_ that returns a list of IO actions +play f = paint $ sequence_ . f + --- Sample usage: paint the doodle at once. -fast = paint $ sequence_ . take 300 . doodle +fast = play $ take 300 . doodle --- Sample usage: make every second action a sleep. -slow = paint $ sequence_ . intersperse (Thread.sleep 100) . take 300 . doodle +slow = play $ intersperse (Thread.sleep 100) . take 300 . doodle + + diff --git a/client/src/main/frege/org/frege/Application.fr b/client/src/main/frege/org/frege/Application.fr index 9a5b708..a9161f5 100644 --- a/client/src/main/frege/org/frege/Application.fr +++ b/client/src/main/frege/org/frege/Application.fr @@ -55,8 +55,8 @@ showUI mConsole stage = do items.add "mapM println [1..100]" items.add "fib = 1n : 1n : zipWith (+) fib (tail fib)" items.add ":l https://raw.githubusercontent.com/Dierk/frepl-gui/master/Stairs.fr" - items.add "import Stairs;import org.frege.SketchBook;import Data.List" - items.add "paint $ sequence_ . take 300 . doodle" + items.add "import Stairs;import Data.List" + items.add "play $ take 300 . doodle" sm <- historyLV.getSelectionModel sip <- sm.selectedItemProperty