Code snippet (ml file):
module H = Tyxml.Html
let render param =
H.html (H.head (H.title (H.txt "title")) [])
(H.body [ ]);;
let html_to_string html =
Format.asprintf "%a" H.pp() html;;
Error:
Error:
File "server/a_07_template.ml", line 10, characters 18-22:
10 | Format.asprintf "%a" H.pp() html;;
^^^^
Error: This expression has type
('a -> 'b, Format.formatter, unit, unit, unit, 'a -> 'b)
CamlinternalFormatBasics.fmt
but an expression was expected of type
('a -> 'b, Format.formatter, unit, unit, unit, string)
CamlinternalFormatBasics.fmt
Type 'a -> 'b is not compatible with type string
File "server/a_07_template.ml", line 10, characters 18-22:
10 | Format.asprintf "%a" H.pp() html;;
^^^^
Error: This expression has type
('a -> 'b, Format.formatter, unit, unit, unit, 'a -> 'b)
CamlinternalFormatBasics.fmt
but an expression was expected of type
('a -> 'b, Format.formatter, unit, unit, unit, string)
CamlinternalFormatBasics.fmt
Type 'a -> 'b is not compatible with type string
Code I was reading at at the time: dream/tyxml.re at master · aantron/dream · GitHub