Replies: 1 comment 7 replies
-
Ok so as with other things we're constrained by the lack of customisable infix operators. Some ideas: fast("3 4","bd sd") // currently supported (I think)
fast("3 4".out("bd sd")) // Implied by the above is that structure comes from the second parameter, i.e. values are taken _out_ of the first one and put into the structure of the second. So we could use 'out' to explicitly state this alignment. Or perhaps calling this 'in' would be better, relative to the righthand argument (which is the 'source pattern').. It's all relative!
fast("3 4".squeeze("bd sd")) // This allows different alignments, like squeeze, trigzero etc
fast(squeeze("3 4", "bd sd")) // Or maybe this is nicer?
squeeze("3 4", "bd sd").fast() // Or this?
"bd sd".every(3, fast("3 4")) // But then there's the issue of automatic currying.. How can that be supported while allowing alignments to be specified?
"bd sd".every(3, x => fast("3 4".squeeze(x))) // A lambda helps, but is fiddly
"bd.sd".every(3, fastSqueeze("3 4")) // An alias can help, but then we're back in the matrix of possible functions..
"bd sd".every(3, fast("3 4").squeeze) // This could be nice, not sure if it's possible.. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm exploring different ways of aligning things in tidal at the moment, on the cycseq branch. It'd be good to explore how this could be brought into strudel. Duck typing in javascript might turn out to be helpful.
In strudel (and tidal), the 'patternify' function uses
innerJoin
, giving us a 'structure comes from the source pattern' rule of thumb.But what if we wanted to use a squeezeJoin instead? A
fast
function that used squeezeJoin instead would treat"a b".fast("2 3")
as[a b]*2 [a b]*3
ora*[2 3] b*[2 3]
depending on the direction of the squeeze (squeezeIn or squeezeOut).Relatedly we are generating a large matrix of operations for combining patterns,
addSqueeze
,mulTrigzero
etc, etc. There is a matrix because each operation does two things from two sets of possibilities - each one first aligns two patterns before combining them together.One answer to both these problems is to separate out the two operations. So first you align patterns, then you do something with them, whether it's adding two patterns of numbers together, passing the patterns as arguments to a function, stacking them up, catting them, or something else..
The haskell syntax I'm exploring for this looks like:
Where
<#
is an operator for aligning two patterns using 'squeeze'. This operator doesn't create a new pattern, but rather an alignment of two patterns as a distinct type, which a function likefastA
oraddA
then uses to make a new pattern.I think it is nice to keep the 'structure from source' and 'structure from left' conventions but it would be great to find a nice syntax for this in strudel.
Got to run now but will add more thoughts about how this could look later !
Beta Was this translation helpful? Give feedback.
All reactions