hello stefan,

On Mon, Jun 9, 2008 at 10:03 PM, stefan kersten <[EMAIL PROTECTED]> wrote:
> when working with ugens with lots of arguments, i think it could be
> helpful to have infrastructure or conventions for named arguments,

i tend to agree

> maybe it's possible to help writing the boilerplate with template
> haskell? alternatively (somewhat more overhead): if we had some kind
> of ugen database describing rates, inputs, outputs, documentation and
> code examples in different languages, things like these could be
> autogenerated (in fact most of the haskell ugen library).

yes, the database idea is definitely a good one, in fact i used
something of the sort when doing the initial scheme/haskell/sml
bindings were done, the sclang & haskell sources are at:

http://slavepianos.org/rd/sw/sw-87/

it's not quite straightforwards to automate _all_ of this for a number
of reasons, ie. sclang doesn't annotate which ugens are non
deterministic, or which are 'filters' (the bindings i've done require
rate arguments for fewer ugens etc.), it's not always clear which
arguments are 'psuedo' arguments (ie.  number of channels etc., which
i've pulled out and put before the rate argument to reduce my own
confusion level) etc. etc. also sclang reorders some arguments from
the actual ugen implementation, mostly to get variable length
arguments out of the last slot.  ideally all of this information would
be pushed into the sclang classes so that a sclang function can spit
out accurate and usable bindings for whatever language people care to
use, but it is a little bit of work...

and of course haskell records have some peculiarities, in terms of
namespace, though ghc is somewhat better than haskell98.

> Pitch.pitch'
>        (mix (soundIn (mce audioInputChannels)))
>         Pitch.defaults { Pitch.initFreq = 100 }

using the 'def' typeclass trick and a separate module for these
constructors you could perhaps get this down to:

  import Sound.SC3.UGen.Record
  pitch input def { Pitch.initFreq = 100 }

or why not put input in the options?

  pitch def {Pitch.input  = input, Pitch.initFreq = 100 }

i agree this would make life better for the rare very discursive
ugens, especially when reading code, though i'd still have to look up
the help file for the names of the arguments when writing, not so sure
it'd be a win for sinOsc and ringz etc. etc.

of course will gratefully accept any patches that you make!
(including of course hand written ones for particularly hard cases
such as pitch...)

regards,
rohan

ps. making various forms of ugen constructors is i think a good idea,
and relatively painless, instead of writing:

  import Sound.SC3

one only has to write

  import Sound.SC3.Server
  import Sound.SC3.UGen.ConstructorForm

this already exists for:

  import Sound.SC3.UGen.Base
  import Sound.SC3.UGen.Monadic
  import Sound.SC3.UGen.Unsafe

and intermingling usages is not too painful either with single letter
qualifiers, the current emacs mode writes out a default hsc3 run
control file with

        "import qualified Sound.SC3.UGen.Base as B"
        "import qualified Sound.SC3.UGen.Monadic as M"
        "import qualified Sound.SC3.UGen.Unsafe as U"

in it...
_______________________________________________
haskell-art mailing list
haskell-art@lists.lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to