XPath Spec support
Closed this issue · 3 comments
I'd like to add some support for Document Object Model (DOM) Level 3 XPath Specification - is this the correct repo, or should a new one be created?
Some implementation questions: for interfaces like XPathEvaluator, is it preferable to implement these as a typeclass that Document is an instance of, or just implement it directly in Document for simplicity, or something else? Of course, if we need to add this in a different repository, neither option works as Document can be directly evaluated - and PureScript doesn't allow orphan instances, so not sure what XPathEvaluator would be in this case.
I'd suggest this should be another library, since it's not part of the core DOM4 spec.
Orphan instances aren't really a problem with the -web libraries, as they don't use classes 🙂. Instead of using classes for subtyping, each interface is declared as a foreign data, operations are declared on this type, and coercions/casts are provided to/from the interface and appropriate types.
@garyb thanks for the clarifications - I'll proceed in that direction.
How should exceptions be modeled, if at all? I didn't see e.g. DOMException in the library, though maybe I missed it.
Hmm, exceptions aren't handled very well, to be honest - in that's it's basically "you're in Effect, anything can happen" and they're catchable by the stuff in purescript-exceptions.