functional-programming-jargon icon indicating copy to clipboard operation
functional-programming-jargon copied to clipboard

Avoid polluting globals

Open MartinMuzatko opened this issue 6 years ago • 2 comments

Hey there! I think for the sake of simplicity, you extend the prototype of Array. To communicate best practices, I'd like to come up with examples that do not extend the global Array object.

The alternative, to create objects from scratch is also more real-world oriented.

Here is a list of examples that use prototype

Thank you.

MartinMuzatko avatar Oct 31 '19 16:10 MartinMuzatko

While I agree, we'd have to either create our own List or some other type that implements all the relevant type classes. I have mixed feelings on whether that'd make it harder to understand

  • if we choose to create List is the reader gonna ask "Why are you reimplementing array in a feature-poor way?"
  • If we choose Maybe then it may be trying to teach too many ideas at once.
  • If we choose Identity then it becomes hard to justify as valuable and stay terse.

jethrolarson avatar Mar 02 '22 20:03 jethrolarson

Maybe defining everything in terms of static-land instead of fantasy-land would be better. https://github.com/fantasyland/static-land

jethrolarson avatar Mar 02 '22 20:03 jethrolarson