glennsl / rescript-jest

ReScript bindings for Jest
MIT License
292 stars 61 forks source link

Implement some mechanism for adding custom assertions #5

Closed glennsl closed 6 years ago

glennsl commented 7 years ago

To replace expect.extend. It'll most likely just be ordinary functions, but would need to use some kind of API.

glennsl commented 6 years ago

Closing to avoid using issues as TODO list, since open issues are penalized by npms.io and issues badge

wyze commented 6 years ago

@glennsl I'd love to see this implemented. I wouldn't mind putting in the work. Do you have some thoughts/suggestions on the changes needed to make this happen?

glennsl commented 6 years ago

I don't, unfortunately. Extensibility in OCaml in general is something I've been meaning to look into, but I'm not using OCaml at all these days so it's unlikely I'm going to do so in the foreseeable future.

More generally, using polymorphic variants in place of ordinary variants can be very useful since they're structural and can be composed in an ad-hoc manner. But they come with significant costs, like leaking implementation details, confusing error messages and no GADTs, which is used here (though it doesn't necessarily need to I think).

Using functors is another possibility, but composing several unrelated extensions using functors will likely involve quite a bit of boilerplate. Like the kind of delegation used to scale the Elm Architecture, if you're familiar with that.

Sorry I can't be of more help, but feel free to hack around and propose changes. But if you do, please try to explore and explain the trade-offs, so it's easier for me to decide whether or not to merge them. Otherwise it might take some time :)