Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tree deconstruction helper #8

Closed
aantron opened this issue Mar 14, 2016 · 0 comments
Closed

Add tree deconstruction helper #8

aantron opened this issue Mar 14, 2016 · 0 comments

Comments

@aantron
Copy link
Owner

aantron commented Mar 14, 2016

This would convert DOM-like data structures into signal streams (the dual of Markup.tree):

val from_tree :
  ('a ->
    [ `Element of string * (name * string) * 'a list
    | `Text of string ]) ->
  'a ->
    (sync, signal) stream

with usage such as

type my_tree = Element of name * my_tree list | Text of string

dom
|> from_tree (function
  | Element (name, children) -> `Element (name, [], children)
  | Text s -> `Text s)
|> write_xml
|> to_string

Perhaps the result type of the function argument can support comments and others nodes besides text and elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant