-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make curried function composable #36
Comments
I suggest priority on rewrite of |
#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 This approach would be a challenge for stuff like this though: as chopping implies changing the structure of the outer But I think |
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)),
) |
#390 was reverted, due to performance issues discussed in #487, so we still don't have composable functions. One solution could be proxies. The below is const handler = {
get: function (target, prop, receiver) {
// chain pattern methods
if (prop in Pattern.prototype) {
return((...args) => new Proxy((pat) => target(pat)[prop](...args), handler));
}
return Reflect.get(target, prop);
},
};
const proxify = func => new Proxy(func, handler);
const hitch = proxify(id);
$: s("bd sd").apply(hitch.n("<2 4>").chop(32).jux(rev).fast(2)) |
Attempt at building this into |
Curried functions are currently not composable:
this works:
this doesn't work:
error:
add(...).velocity is not a function
this works:
ideally, all curried functions need to have all pattern methods.
This is what
makeComposable
is supposed to do, but it does not seem to workThe text was updated successfully, but these errors were encountered: