-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Highland.js Integration #1037
Comments
Ramda looks fun, I'll have to take it for a spin :) Seems a good match for Highland. Perhaps it would be a good opportunity to produce a more 'skinny' Highland core for you to integrate too... |
some background: we already can dynamically dispatch to non-list objects in list position. That's how we support transducers, and how we are implementing the fantasy-land spec. so in some (many?) ways highland may just drop right in with ramda and work, e.g., So I'd like to firm this up s.t. you can just drop it in and start using it point-free. full disclosure: I'm working on a relational programming thing that i want to recast to use streams. so this is personally useful to me 😸 |
Yeah, |
Interesting...so we'll need to figure out a list of Highland <-> Ramda operator equivalencies. We'd also have to make sure their semantics match. One possible issue is that sometimes the names don't match between the two libraries. For instance, Plus, due to the nature of the two libraries, Ramda implements more operators than Highland does (e.g., |
The Ramda implementation of One thing I proposed when discussing the transformer protocol was to use Ping @tgriesser as he may have thoughts on this as well. |
Yeah, if we were still in the pre-1.0.0 phase we could probably make the case for changing the parameter order of I've compiled a list of Highland transform functions and their equivalents in Ramda excluding a few of the more stream specific ones though:
var xs = [1, 2, 3, 4, 5];
hl.batch(2, hl(xs)); // => [1, 2], [3, 4], [5]
R.aperture(2, xs); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
var xs = hl(['ba', 'a', 'a']);
hl.intersperse('n', xs); // => ba, n, a, n, a
var xs = hl([1,2,3])
hl.zipAll([[4, 5, 6], [7, 8, 9], [10, 11, 12]], xs)
// => [ [ 1, 4, 7, 10 ], [ 2, 5, 8, 11 ], [ 3, 6, 9, 12 ] ]
|
|
I'd be more than happy to help out with some of those PRs, if you want. Although, that said, you'd probably get the three done in the time it took me to do one because no doubt I'd make a bunch of n00b mistakes with the build. Its a bit of an intimidating process to say the least. |
thanks @svozza i can probably bang 'em out pretty quick. i am interested to hear if you have ideas about making contributing easier though. but that is yet another discussion .... |
Hehe. Yeah, let's stick to one thing at a time. Anyway, the offer is there if you get sidetracked. |
@buzzdecafe Notice that |
fair enough @bergus i will add that to my PR-TODO list |
Something like Is there any appetite for some sort of user-defined aliasing capability that would allow us to dispatch on different names? This might possibly include a lodash-style |
couple more:
would be nice to have these integrated, and treat streams as fantasy-style monads |
We're looking at Fantasy Land compatibility after 3.0. Discussion and WIP implementation is at caolan/highland#114. Part of this is aliasing |
|
We also have
Highland folks, do we want to consider fixing some of the naming & arg order issues in 3.0? Or would that complicate things even more? |
I'd definitely be in favour of changing the names and argument orders for 3.0. That said, @CrossEye 's suggestion about the user defined aliases could be very nice too. The 'glue' to get the two libraries to work together could live in a separate module so it would reduce the impact on the core of both APIs. |
FWIW i think in the near term at least that is going to wind up being the solution. |
Perhaps we should create ramda/ramda-highland and add the Highland contributors. Alternatively, @caolan could create caolan/highland-ramda and we could collaborate there. |
Yeah, that sounds like a good plan. Probably makes sense to go for ramda/ramda-highland as we're still trying to figure out what way to go for extensions to the Highland. |
I've created an empty repository at ramda/ramda-highland. We can discuss specifics over there. |
Ok, I guess. But from Ramda's point of view, I would hope that Highland is just one possible integration, and that there is no specific Ramda internal code to make it work (except for fundamental infrastructure usable by any integration.) |
I agree that Ramda should have no specific knowledge of Highland. A compatibility layer seems to me a reasonable way to resolve API differences between the two projects. |
I wonder how much of the Ramda API can be implemented via the Fantasy Land Monad interface + transducers + Lots of common operators can be implemented as transducers (e.g., Fantasy Land can help this along even more. I implemented partial Fantasy Land support + Getting integration this way could actually go pretty far, and would reduce the size of the compatibility layer. (*)The caveat here is that Highland can't actually implement -- C for collection
-- C can be [] or HL or whatever type implements reduceC
reduceC :: ((acc, x) -> acc) -> acc -> C x -> C acc This means |
Yes, and it's a much less invasive way for us than having to add several aliases to the Highland core. |
I've been considering ways for Ramda to easily support such compatibility layers, and it strikes me that what we want is to offer configuration at the dispatch level. Something like
that possibly also takes some rearg configuration. And then the dispatching mechanism would know to look for either 'pairs' or 'toPairs' on the object in question. |
There's a huge downside to my suggestion, though, perhaps insurmountable: it would introduce state |
As Ramda supports transducers in more list functions, I'm also wondering how much can be done directly with transducers + Fantasy Land. Probably quite a bit. The "compatibility layer" of transducers + |
@CrossEye When you say |
@wayneseymour Yes, that's what I mean. Right now. all Ramda functions will return the same results for the same parameters. But if we added the ability to dynamically change the aliases for dispatching, then this would no longer be true: var hand = new PokerHand(['4d', 'Jh', '2c', '4h', '7s']);
R.toPairs(hand);
//=> [
// ['cards', ['4d', 'Jh', '2c', '4h', '7s']],
// ['pairs', [['4d', '4h']]],
// ['threesOfKind', []],
// ['straight', null],
// /* ... */
// ]
R.alias('toPairs', 'pairs'); //=> ??
R.toPairs(hand); //=> [['4d', '4h']] We've lost our referential integrity. |
Is it possible to have var R = require('ramda'),
_ = require('highland');
// Ramda-for-Highland
var HighlandR = R.alias([
['chain', 'flatMap']
...
];
console.log(R === highlandR); // => false
R.split(R.add(1), [1, 2, 3, 4]); // => [2, 3, 4, 5]
R.split(R.add(1), _([1, 2, 3, 4])); // => some errror.
HighlandR.split(HighlandR.add(1), _([1, 2, 3, 4])).toArray(_.log); // => [2, 3, 4 ,5]
HighlandR.split(HighlandR.add(1), [1, 2, 3, 4]); // => some error |
@CrossEye could we consider something like Bilby's environments? var hand = new PokerHand(['4d', 'Jh', '2c', '4h', '7s']);
R.toPairs(hand);
//=> [
// ['cards', ['4d', 'Jh', '2c', '4h', '7s']],
// ['pairs', [['4d', '4h']]],
// ['threeOfKinds', []],
// ['straight', null],
// /* ... */
// ]
var R_ = R.withAlias('toPairs', 'pairs');
R_.toPairs(hand); //=> [['4d', '4h']]
R.toPairs(hand);
//=> [
// ['cards', ['4d', 'Jh', '2c', '4h', '7s']],
// ['pairs', [['4d', '4h']]],
// ['threeOfKinds', []],
// ['straight', null],
// /* ... */
// ] edit: @vqvu got there before me :) |
Yes, that could work. It would take some interesting reworking of Ramda's internals. And a user who doesn't mind could always assign this right back to |
@CrossEye |
closed for inactivity |
We had a bit of a discussion here about possibly integrating Highland streams into Ramda so I said I'd create an issue here explore the issue more fully. @caolan has been very busy recently so I'm not sure if he has time to get involved but after him @vqvu probably knows the code better than anyone else - not to mention @jeromew, @LewisJEllis and @quarterto - and I'm sure we can all help in some way. What do you have in mind and what would you need from our side?
The text was updated successfully, but these errors were encountered: