ramda: Error checking
@buzzdecafe Commented on a now outdated diff in #464
now we expect the user to pass in the right stuff without us enforcing it. e.g. we don’t check the fn passed to
map
,foldl
, etc.
After some real world use of ramda, my stance is that I don’t agree with this. If any of the functions in ramda is used on its own then yes, type checking is probably not needed. But when combining several functions with compose
, useWith
or just inlining calls to them, errors can happen pretty easily and the stack trace can be a bit cryptic. I think that if users received messages like
R.map expects the first argument to be a function but actually got the string "foo"
it would be yet another reason to love this lib.
I think it would be easy to create a single internal function that does error checking and produces well formatted error messages if anything is wrong.
If this seems like a good idea then I am happy to investigate how this feature could be added with and input to functions validated with minimal effort.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 38 (36 by maintainers)
Sanctuary is worth a look, @brandones. See https://github.com/ramda/ramda/pull/2047#issuecomment-272064266 for an example of its descriptive error messages.