purescript-jquery
purescript-jquery copied to clipboard
Selecting document, window, HTMLElements, et.c.
It looks like the only thing you can us as a selector is String, but it's heavily overloaded in jQuery. e.g. $(document).ready, $(window).on("popstate"), $(document.body), $($("why")). Has anyone given this any thought?
I'd suggest that special operations be completely separate functions, such as ready already is for $(document).ready, and we could have selectWindow and selectDocument for $(window) and $(document) respectively. This way it is possible to use these objects as normal elements, but you can certainly misuse these. Another option would be adding a type parameter to JQuery, that way we may be able to be more granular in type signatures.
In fay-jquery we chose to only allow elements, strings, and jquery objects as input to select.
I'd be interested in adding the functionality you describe, either via multiple monomorphic functions like selectWindow, or type classes. I think I'd prefer the former though.