strudel
strudel copied to clipboard
make curried function composable
Curried functions are currently not composable:
this works:
"c3".superimpose(
add(3),
add(7),
)
this doesn't work:
"c3".superimpose(
add(3).velocity(.5),
add(7),
)
error: add(...).velocity is not a function
this works:
"c3".superimpose(
x => x.add(3).velocity(.5),
add(7),
)
ideally, all curried functions need to have all pattern methods.
This is what makeComposable is supposed to do, but it does not seem to work
I suggest priority on rewrite of compose https://github.com/tidalcycles/strudel/issues/35, as it would help confine current issue
#35 is done now. still not sure how to approach this. I thought it would be possible with a custom curry function (with additional overload function), but it's tricky. Some people use Proxy for this https://medium.com/dailyjs/haskell-like-composition-in-javascript-6142a2a82821 . Of course this could be fixed more easily on the eval side, but it then wouldn't work without it.
Maybe this problem can be solved much easier by flipping it around: https://strudel.tidalcycles.org?fpNMjYivvAhZ
Bringing discussion from #264.. Maybe we should move all the currying inside the patterns.
So add(3) returns a pattern of functions. Then add(3).mul(.5) composes together two patterns of functions, and add(3).mul(.5).fast(2) speeds up that pattern of functions.
This approach would be a challenge for stuff like this though:
s(3).n(2).every(2, add(n(3)).chop(3) )
as chopping implies changing the structure of the outer s(3).n(2) pattern, which I think the chop is too far away from..
But I think s(3).n(2).every(2, add(chop(3).n(3))) would be ok.
This is working now via #390 , as
note("c3").superimpose(
add.note(3).velocity(.5),
add.note(7),
)
or
note("c3").superimpose(
add(note(3)).velocity(.5),
add(note(7)),
)