You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Transducers are a particularly challenging thing to do in typescript do to how "functions that act as transformers" are isomorphic to them
consta=[1,2,3];constf=R.compose(R.map(R.multiply(2)),R.map(R.add(3)),);// compose runs the array values through the first map and then the secondf(a);// [5,8,11]// transduce runs the init transformer into the multiple transformers into the add transformerR.transduce(f,R.flip(R.append),[],a);// [9, 12, 15]
Now while the above example works fine, once you start transitioning through the types it gets weird quickly
consta=[1,2,3];// this is completely contrived but gets the point acrossconstf=R.compose(R.map(R.toString()),R.map(R.add(3)),);f(a);// ['3', '6', '9'];// because now `toString` is processed first, `add` does string concatenationR.transduce(f,R.flip(R.append),[],a);// ['13, '23', '33']
Typescript doesn't have "look-ahead" capabilities where it can see where a function is used to determine what its type should be for isomorphic behavior like this
The only way around this that I can think of is to have a separate function for compose and pipe that is typed specifically to the order of operation here
The text was updated successfully, but these errors were encountered:
Transducers are a particularly challenging thing to do in typescript do to how "functions that act as transformers" are isomorphic to them
Now while the above example works fine, once you start transitioning through the types it gets weird quickly
Typescript doesn't have "look-ahead" capabilities where it can see where a function is used to determine what its type should be for isomorphic behavior like this
The only way around this that I can think of is to have a separate function for
compose
andpipe
that is typed specifically to the order of operation hereThe text was updated successfully, but these errors were encountered: