[PD] Haskell external for Pd (Was: Re: Thanks for you patience.)
Claude Heiland-Allen
claudiusmaximus at goto10.org
Wed Mar 7 00:30:53 CET 2007
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-twofivesixspheres.png
Claude
--
http://claudiusmaximus.goto10.org
More information about the Pd-list
mailing list