-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Clarify Ramda <-> Sanctuary relationship #317
Conversation
The only issue with the new description is that with v0.12 comming out soon, this version will remove the dependency on ramda and generally replace it with Sanctuary Type Classes. I have been thinking about this for a bit and maybe one way to describe one of the fundamental differences between Sanctuary and Ramda (aside from a type checker) would be to say that Sanctuary is more of a framework providing a Functional type system based on Fantasy Land, creating an environment that makes it easier to program in "Category style" (Building your program up from smaller types, composition, etc.). As opposed to Ramda which works more like a library of "functional functions" which you can pick and choose what you want, from using just a couple functions in an otherwise OOP application to writing in full Category style. Sanctuary is not as well suited for the former when you have to constantly interact with non-functional code while Ramda is a bit clumsier in the latter. |
@Shard It's a good point that Sanctuary forces the developer into a certain paradigm (for lack of a better word), where Ramda is much less opinionated in that regard and can be used more as a pick-what-you-want. One could say working with Sanctuary commits you to a certain style of programming, unlike Ramda. My main concern is that we should be careful using too abstract and vague terms without either giving examples or bringing it down to a more concrete level. (Perhaps we want to clarify it briefly in the top of the README and then elaborate in a section further down with code examples. I think that might be the optimal way.) @davidchambers and I talked a bit about the wording in #232 and arrived at:
Throwing a new draft out there:
|
I gave it a new shot, tell me what you think. |
index.js
Outdated
//. Sanctuary is a functional programming library inspired by Haskell | ||
//. and PureScript. It's stricter and more opinionated than [Ramda][], | ||
//. and provides a similar suite of functions. | ||
//. Sanctuary is a functional programming library inspired by Haskell and PureScript. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the text wrapped at 79 characters. :)
index.js
Outdated
//. and PureScript. It's stricter and more opinionated than [Ramda][], | ||
//. and provides a similar suite of functions. | ||
//. Sanctuary is a functional programming library inspired by Haskell and PureScript. | ||
//. It provides a similar suite of functions as [Ramda](https://github.com/ramda/ramda), but in a stricter and more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use [Ramda][]
here rather than [Ramda](https://github.com/ramda/ramda)
.
index.js
Outdated
//. opinionated way, ensuring errors are properly handled. | ||
//. Sanctuary makes it easy to build a program up from smaller types and functions | ||
//. and makes it possible to write safe code without constant null-checks. | ||
//. It uses and provides the two [Fantasy Land](https://github.com/fantasyland/fantasy-land)-compatable monads Maybe and Either. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's replace [Fantasy Land](https://github.com/fantasyland/fantasy-land)
with [Fantasy Land][]
, and add this link reference at the bottom of the file:
//. [Fantasy Land]: v:fantasyland/fantasy-land
See #324 if you'd like to know the significance of the v:
above.
index.js
Outdated
//. properly handled. | ||
//. Sanctuary makes it easy to build a program up from smaller types and | ||
//. functions and makes it possible to write safe code without constant | ||
//. null-checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the word "composition" in the paragraph above. How about something like this?
Sanctuary promotes programs composed of simple, pure functions. Such programs are easy to test, comprehend, and maintain, and a pleasure to write.
Sanctuary provides two Fantasy Land -compatible data types, Maybe and Either, which mean that even functions which may fail—such as head
—are composable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's definitely the better wording!
Thanks for the updates, Jacob. I like the direction you've taken with this. :) |
index.js
Outdated
//. pleasure to write. | ||
//. Sanctuary provides two [Fantasy Land][]-compatible data types, | ||
//. Maybe and Either, which mean that even functions which may fail | ||
//. — such as `head` — are composable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that's unclear is whether the text above is meant to be one paragraph or three. Since we're using Markdown, paragraphs must be separated by empty lines. If you intend the text above to be three paragraphs, please add empty lines to separate the paragraphs. If you intend the text above to be a single paragraph, please make this clear by having the sentences flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful for "Maybe", "Either", and "head
" to link to their respective sections in the document. Do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidchambers yes, do you want me to link them directly (e.g. Maybe)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please. I think these link definitions would be most appropriate:
//. [Either]: #either-type
//. [Maybe]: #maybe-type
//. [`head`]: #head
👍 |
I'm sorry that I haven't looked at this for a couple of weeks, Jacob. I'm about to do so. :) |
By the way, the reason the commits are not attributed to you is that the author and committer email address is set to I'm about to squash your commits and rebase your branch, so soon there'll be a single commit with you as the author and me as the committer. |
index.js
Outdated
//. and provides a similar suite of functions. | ||
//. Sanctuary is a JavaScript functional programming library inspired | ||
//. by Haskell and PureScript. It's stricter and more opinionated than | ||
//. [Ramda][], and provides a similar suite of functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed "functional programming library" to "JavaScript functional programming library". It can't hurt to make this clear.
I made a few tweaks. Could someone have a look at the updated pull request before I merge it? You may like to view the rendered readme. |
Maybe add spaces before and after
Do we need this dash? |
index.js
Outdated
//. and PureScript. It's stricter and more opinionated than [Ramda][], | ||
//. and provides a similar suite of functions. | ||
//. Sanctuary is a JavaScript functional programming library inspired | ||
//. by Haskell and PureScript. It's stricter and more opinionated than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what "more opinionated" means in this context, and whether it conveys any useful information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might mean that Sanctuary has a bigger impact on how one structures their code, in which case it may be more informative to add that to the introduction instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that "more opinionated" doesn't convey much information. I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡
You have an eye for typography, Irakli!
I avoid EM DASH (U+2014) in source code because some text editors do not render it nicely and it's difficult to differentiate from EN DASH (U+2013), especially in a fixed-width font. On the other hand, I also dislike having I avoided these issues by switching to commas. :)
I agree that this looks awkward. The usage notes in the entry for well in the dictionary on macOS:
So one would write a Fantasy Land -compatible data type or the data type is Fantasy Land compatible. I include a space before the hyphen in the first case because we want compatible to apply to Fantasy Land rather than just Land. I'll attempt to reword the sentence so we can use the unhyphenated form. :) |
index.js
Outdated
//. similar suite of functions. | ||
//. | ||
//. Sanctuary promotes programs composed of simple, pure functions. | ||
//. Such programs are easy to test, comprehend, and maintain, and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might remove some ambiguity if the Oxford comma between comprehend
and and maintain
is removed. It would signify the end of the list thus removing the programs are easy to a pleasure to write
-problem:
EDIT: Such programs are easy to test, comprehend and maintain, and a pleasure to write.
Looking at it, I'm not sure. Maybe we can make the last and
cursive, or change it to and they're a pleasure
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively re-word it a la Such programs are not only a pleasure to write, they are also easier to test, comprehend, and maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ❤️ this suggestion, Jacob. I'll make the change now.
p.s. I'm sorry for commandeering your pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidchambers haha please commandeer away, first time I ever contribute to such large a project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jacse, since this pull request was your initiative and all I have done is apply patches based on suggestions (including a few of my own suggestions), I will squash the patches into your original commit. You will be marked as the author, I will be marked as the committer, and we will have a clean commit history. :)
index.js
Outdated
//. similar suite of functions. | ||
//. | ||
//. Sanctuary promotes programs composed of simple, pure functions. Such | ||
//. programs are not just a pleasure to write; they are easy to comprehend, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion @Jacse. I think only
reads better than just
in this kind of construction @davidchambers. And we may yet flip it around: "Such functions are not only easier to comprehend, test, and maintain; they are also a pleasure to write." I always like the "reward" to appear at the end of the sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ❤️ this suggestion, Aldwin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡
Thanks for chiming in on Gitter, @nlindley. Thanks everyone for your feedback and many good suggestions. The time and attention we've devoted to these Let's merge this pull request. Could I get a |
The relationship between Sanctuary, Ramda, and even Ramda-fantasy is currently pretty difficult to get a solid grip on for a newcomer like myself. I have found that information is surprisingly difficult to obtain, but in the end I found the relationship clarified very well by @davidchambers in #178.
Making such a small change to the README would make a huge difference. Maybe a small section along the lines of "Ramda vs. Sancuary" should be added as well, explaining the main differences of using just Ramda, Ramda with monads from Ramda-fantasy, and using Sanctuary. This section could also clarify that one currently has to use Ramda and Sanctuary alongside each other but in the future Sanctuary can be used on its own.
Some examples of the confusion in the community can be seen at Ramda issue #1610, Ramda issue #1641, Ramda issue #1391.
Ramda will try to clarify the relationship from their side in the upcoming Ramda manual.