Skip to content
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

Implement the Array API #27

Closed
wants to merge 9 commits into from
Closed

Conversation

gabejohnson
Copy link

@gabejohnson gabejohnson commented Mar 8, 2018

I've started by copying the code from https://github.com/purescript/purescript-arrays/blob/master/src/Data/Array.purs and modifying it to use this list implementation.

I've chosen to simplify the FFI JS files by using Fn<n>, runFn<n> and mkFn<n> instead of manually currying. There is less potential for errors using this strategy and the possibility of future compiler optimizations.

updateAtIndices, modifyAtIndices, sort, sortBy , sortWith, group, group', and, groupBy have yet to be implemented (I also didn't write an Ord instance).

I implemented Traversable as a placeholder until it's available "natively".

There's certainly room for improvement in organization and documentation.

Note: The doc comments are barely changed from those in -arrays and I'm unsure what the licensing implications are.

@gabejohnson
Copy link
Author

You might also notice the Show instance results in

show $ fromFoldable [1, 2, 3] == "<1,2,3>"

This is a placeholder until a proper representation is chosen.

@paldepind
Copy link
Member

This looks really great.

I've chosen to simplify the foreign FFI JS files by using Fn<n>, runFn<n> and mkFn<n> instead of manually currying. There is less potential for errors using this strategy and the possibility of future compiler optimizations.

That definitely looks like a better approach than what I was doing before.

I implemented Traversable as a placeholder until it's available "natively".

If List implemented Traversable based on Fanasy Land would that be useable in PureScript?

Do you think having this as a purescript folder here is fine or should I set up a repository specifically to it?

@paldepind
Copy link
Member

This is a placeholder until a proper representation is chosen.

I think

show $ fromFoldable [1, 2, 3] == "fromFoldable [1, 2, 3]"

would be an appropriate representation.

In JavaScript I'm thinking that

list(1, 2, 3).toString() === "list(1, 2, 3)"

@gabejohnson
Copy link
Author

If List implemented Traversable based on Fanasy Land would that be useable in PureScript?

No it wouldn't. You're welcome to improve the efficiency of the current implementation of course 😄

@gabejohnson
Copy link
Author

gabejohnson commented Mar 16, 2018

Do you think having this as a purescript folder here is fine or should I set up a repository specifically to it?

Idk. That's probably a better question for the #purescript Slack

@paldepind paldepind force-pushed the master branch 2 times, most recently from 7807de5 to 9c81940 Compare March 18, 2018 11:04

exports.length = function length(l) {
return l.length;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List exports a length so this could be exports.length = L.length.

if (!f(L.nth(i, xs))(L.nth(i, ys))) return false;
}
return true;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding an equalsBy to List itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see general utility for equalsBy?

@gabejohnson gabejohnson changed the title [WIP] Implement the Array API Implement the Array API Apr 3, 2018
@gabejohnson
Copy link
Author

@paldepind I've make some changes/additions.

@gabejohnson
Copy link
Author

@paldepind I didn't want to presume anything about the documentation style or how you might want to include examples and algorithmic complexity.

If you want to merge this as-is and tackle the docs yourself that would be great. Otherwise, I'd like some guidance concerning style/examples when you have time.

@paldepind
Copy link
Member

@gabejohnson

What do you think about the name purescript-rrb-list as suggested in hdgarrood/purescript-sequences#31?

If you think that name is fine then I suggest the following: I create a new GitHub repository in Funkia with that name, you create an identical PR for that repo, I merge it and publish it to Pursuit. Then PS users can actually start trying the library and additional improvements can be based off of that 😄

Btw, I highly appreciate the work you've done in this PR!

@gabejohnson
Copy link
Author

Honestly I don't like -rrb-list because I care about the performance characteristics, not the implementation (which I don't assume the user is going to glean from seeing rrb).

Maybe -fast-list?

@gabejohnson
Copy link
Author

That said, I don't want to hold things up. I know there's a market for a data structure like this.

@gabejohnson
Copy link
Author

purescript-funkia-list is another possibility. It was mentioned in Slack that calling it anything else might mislead people to think it's implemented in PS.

@paldepind
Copy link
Member

purescript-funkia-list is a fine name as well. But, I'm not sure that the Funkia name means anything to people. I think the fact that it is a JavaScript library should be added to the top of the readme. Similarly to how purescript-array does not indicate that it is JavaScript arrays but it is mentioned in the docs.

I prefer purescript-rrb-list because I think it is the name that best describes what it is 😄

I've created a repo for the PS bindings here: https://github.com/funkia/purescript-rrb-list

@gabejohnson
Copy link
Author

How would you like the package namespaced? RRB.List or Funkia.List?

@paldepind
Copy link
Member

Would the Data prefix be appropriate? Data.RRBList for instance?

@gabejohnson
Copy link
Author

There's a trend moving away from the Data/Control namespacing scheme (see https://github.com/purescript/purescript-effect/blob/master/src/Effect.purs).

The prefix seems unnecessary and arbitrary to me. I think RRBList is fine.

@paldepind
Copy link
Member

Oh, well, that is a trend I can get behind 😄

I think RRBList is fine.

I agree 😄

@paldepind
Copy link
Member

Superceeded by funkia/purescript-rrb-list#1.

@paldepind paldepind closed this Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants