aantron / lambdasoup

Functional HTML scraping and rewriting with CSS in OCaml
https://aantron.github.io/lambdasoup
MIT License
383 stars 31 forks source link

element node to general node coercion #20

Closed copy closed 6 years ago

copy commented 6 years ago

I'm trying to use the Soup.create* api to build up a lambdasoup object manually. This involves conditionally returning nodes created with either Soup.create_element or Soup.create_text. However, the types of the two are incompatible, so I would like to coerce the more specific type (element node) to the more general one (general node), i.e. a coerce : 'a node -> general node (or element node -> general node).

aantron commented 6 years ago

Thanks. I've also needed this function in my own work, and resorted to Obj.magic. There should now be Soup.coerce in master that does this. Would you like a speedy release to opam?

copy commented 6 years ago

Would you like a speedy release to opam?

Whenever it's convenient.

aantron commented 6 years ago

@copy, I'm sure you got the emails already, but this is now in opam as lambdasoup 0.6.3.