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

Util.tree ?element function example inconsistent with its signature in the documentation (?) #61

Closed
OndrejPopp opened this issue Nov 26, 2020 · 2 comments

Comments

@OndrejPopp
Copy link

Hello Anton,
I have just been reading about the parser documentation and it appears to me that the application of the element function is inconsistent with its signature,

So,
?element:(name -> (name * string) list -> 'a list -> 'a)
is a function of three arguments producing 'a

but it is used as,
~element:(fun (name, _) children -> Element (name, children))

which appears to be a function of only two arguments, the tupple (name, _) and children,

See here for the original piece of documentation,
kind regards,
Ondrej

val tree :
?text:(string list -> 'a) ->
?element:(name -> (name * string) list -> 'a list -> 'a) ->
?comment:(string -> 'a) ->
?pi:(string -> string -> 'a) ->
?xml:(xml_declaration -> 'a) ->
?doctype:(doctype -> 'a) ->
([< signal ], sync) stream -> 'a option
This function's type signature may look intimidating, but it is actually easy to use. It is best introduced by example:
type my_dom = Text of string | Element of name * my_dom list

"

HTML5 is easy to parse".
|> string
|> parse_html
|> signals
|> tree
~text:(fun ss -> Text (String.concat "" ss))
~element:(fun (name, _) children -> Element (name, children))

@aantron
Copy link
Owner

aantron commented Nov 26, 2020

This was actually fixed in #50, and is now

markup.ml/src/markup.mli

Lines 554 to 561 in e1aed3c

"<p>HTML5 is <em>easy</em> to parse"
|> string
|> parse_html
|> signals
|> tree
~text:(fun ss -> Text (String.concat "" ss))
~element:(fun (_ns, name) _attrs children -> Element (name, children))
]}

The issue is that Markup.ml's doc generation script is currently broken, and as I haven't gotten around to fixing it, I haven't been able to post accurate docs lately (almost all the docs are still accurate, though). I opened #62 to remind myself to get on it! I'm closing this issue in the meantime.

@aantron aantron closed this as completed Nov 26, 2020
@OndrejPopp
Copy link
Author

Ok, tx Anton! 😃

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

2 participants