I figured out how to do what I want with [until]. Sorry for being so dense. I have a strong leaning toward recursive solutions as I have been programming exclusively in Haskell for years.
#N canvas 243 71 993 768 10; #X obj 15 13 zexy; #X obj 366 135 until; #X msg 201 110 print; #X msg 287 53 rewind; #X obj 366 54 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 238 170 textfile; #X msg 69 54 clear , read test4.txt; #X msg 89 79 clear , read josquin.seq; #X text 72 35 1.); #X text 287 32 2.); #X text 364 30 3.); #X obj 238 276 route do control wait; #X obj 238 214 t a a; #X obj 268 242 print record; #X obj 333 384 delay 100; #X obj 333 353 * 100; #X obj 381 81 r continueTT; #X obj 396 105 r waitingTT; #X obj 332 312 t f b; #X obj 376 335 s waitingTT; #X obj 334 419 s continueTT; #X obj 210 383 print action; #X obj 318 582 until; #X msg 153 557 print; #X msg 239 500 rewind; #X obj 318 501 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 21 501 clear , read test4.txt; #X msg 41 526 clear , read josquin.seq; #X text 24 482 1.); #X text 239 479 2.); #X text 316 477 3.); #X obj 190 723 route do control wait; #X obj 190 661 t a a; #X obj 220 689 print record; #X obj 285 831 delay 100; #X obj 285 800 * 100; #X obj 284 759 t f b; #X obj 162 830 print action; #X obj 190 617 msgfile; #X obj 333 528 r continueMM; #X obj 348 552 r waitingMM; #X obj 328 782 s waitingMM; #X obj 286 866 s continueMM; #X obj 191 639 list trim; #X connect 1 0 5 0; #X connect 2 0 5 0; #X connect 3 0 5 0; #X connect 4 0 1 0; #X connect 5 0 12 0; #X connect 5 1 1 1; #X connect 6 0 5 0; #X connect 7 0 5 0; #X connect 11 0 21 0; #X connect 11 1 21 0; #X connect 11 2 18 0; #X connect 12 0 11 0; #X connect 12 1 13 0; #X connect 14 0 20 0; #X connect 15 0 14 0; #X connect 16 0 1 0; #X connect 17 0 1 1; #X connect 18 0 15 0; #X connect 18 1 19 0; #X connect 22 0 38 0; #X connect 23 0 38 0; #X connect 24 0 38 0; #X connect 25 0 22 0; #X connect 26 0 38 0; #X connect 27 0 38 0; #X connect 31 0 37 0; #X connect 31 1 37 0; #X connect 31 2 36 0; #X connect 32 0 31 0; #X connect 32 1 33 0; #X connect 34 0 42 0; #X connect 35 0 34 0; #X connect 36 0 35 0; #X connect 36 1 41 0; #X connect 38 0 43 0; #X connect 38 1 22 1; #X connect 39 0 22 0; #X connect 40 0 22 1; #X connect 43 0 32 0;
Hi David, and all,
David F. Place wrote:
I have a strong leaning toward recursive solutions as I have been programming exclusively in Haskell for years.
You may be interested in [hsext], an external I'm working on that allows you to create Pd objects in Haskell.
You can check out the current latest and greatest version from SVN, be warned that it's under development and the API will probably change quite a bit before I get it how I want it:
svn co https://devel.goto10.org/svn/maximus/hsext hsext
If you need a "known working" version, revision 213 (the current version as of writing this email) is the one for you:
svn co -r 213 https://devel.goto10.org/svn/maximus/hsext hsext
I plan to change the API to better match Pd's way of doing things (and fix some design mistakes on my part), which should hopefully make the Haskell code clearer and more future-proof too, while also hiding some of Pd's API pains.
Requirements:
ghc-6.4.2 hs-plugins-1.0-rc0 gcc-4.1.1 pd-0.39-2, pd-0.40-2, older versions might work, but I haven't tried.
(ghc-6.6 + hs-plugins-1.0-rc0 = pain, you have been warned)
Simple example (as provided in revision 213):
-- swap two messages (not only individual floats...)
module Swap where
import Data.IORef import PureData
creator :: Creator creator args = do bang <- gensym "bang" state <- newIORef (bang, []) return (Just Instance{iInlets = 2, iOutlets = 2, iMethod = inlet state})
inlet state outlet 0 s m = do (rs,rm) <- readIORef state outlet 1 s m outlet 0 rs rm return ()
inlet state outlet 1 s m = do writeIORef state (s,m) return ()
-- end of example
Complex example (screenshot, the Haskell code generates vectors):
http://claudiusmaximus.goto10.org/gallery/coding/d01234/rev201-twofivesixsph...