-
Notifications
You must be signed in to change notification settings - Fork 106
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Type signatures -- offering a consistent API for easy use #760
Comments
The ocaml solution is to use labeled arguments. Look at BatList.Labels for example. |
Thanks for the suggestion; it is a good alternative. However, BatVect (and many other modules) do not have such a module; are there any plans for adding them/would you accept a PR for it?
Are there any plans to have a future release with a bunch of breaking changes (to include new features)? Perhaps one could add this to the list. |
I am personally not in favour of having more labelled modules. Concerning your other point, the next major release is supposed to have breaking changes. |
I am personally fine with having On the other hand, I don't really believe in the idea of changing Batteries 3 to use a completely different API convention that the current release. Batteries is, in part, defined by the fact that it strives to remain a drop-in extension of the standard library, instead of an opinionated library that defines its own ways to do things are requires you to change your code. If you want library with more innovative designs, there are Jane Street Core (and now Base) and Simon Cruanes' Containers that are both interesting choices. |
Well, the project's readme does mention this near the very top:
but I understand your points -- changing the API so drastically is perhaps too much work for not much benefit and with high costs (users have to change their code, breaking compatibility with the standard library etc.). Okay, so changing the API is out of the question now. @gasche could you ask other maintainers to weigh in on the point about adding Also, does the project have written contribution guidelines? I couldn't find |
* Partial fix for issue ocaml-batteries-team#760. * Also fixes a few typos in the `BatVect` documentation.
* Partial fix for issue ocaml-batteries-team#760. * Also fixes a few typos in the `BatVect` documentation.
I agree with @gasche here. Besides I have an almost common usecase for Concerning the breakage on next major release to get a more consistent interface, I don't have any strong opinion (probably because we have already so many things to break that I don't feel I need to have an opinion on this :) ). |
I'm primarily talking about the
BatVect
module below, but perhaps this point applies to other modules too (I haven't used them much).Having the data structure be the final argument of the function is really useful when using a chain of pipe operators; say you're working with a vector of vectors:
versus a hypothetical
Obviously one can define such functions locally by rearranging the arguments, but I think that the library definitions should offer a consistent API where the last argument is always[1] the data structure for readability of long chains of pipe operations such as this.
Some functions in
BatVect
follow this, such asappend
,concat
etc. but there are many which do not such asmodify
,set
and so on.For example, Haskell's Data.List follows this guideline and this point is explicitly mentioned in Elm's package design guidelines.
[1] For the specific case of
fold
-like operations, I'm not arguing one way or another (for the inner map). In this situation, Haskell and Elm are different. Haskell haswhereas Elm's
foldr
andfoldl
signatures are identical.However, these functions still have the list as the last argument. I can understand that you might want to have the order of arguments be consistent with
Pervasives
and so you have the foldable type as the penultimate argument forfoldr
.The text was updated successfully, but these errors were encountered: