Skip to content
This repository
Browse code

[enhance] stdlib, xhtml: xmlizer take care of type unifiable to list

  • Loading branch information...
commit 6869f4dbfa7f26a082276ea7910dff9a66f0faa9 1 parent 694b170
Quentin Bourgerie BourgerieQuentin authored

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. +9 6 stdlib/core/xhtml/xhtml.opa
15 stdlib/core/xhtml/xhtml.opa
@@ -16,7 +16,7 @@
16 16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 17 */
18 18
19   -import stdlib.core.{web.core, rpc.core, parser, funaction, mutable.buffer}
  19 +import stdlib.core.{web.core, rpc.core, parser, funaction, mutable.buffer, unification}
20 20
21 21 /**
22 22 * {1 About this module}
@@ -536,10 +536,6 @@ XmlConvert = {{
536 536 original_ty = @typeof(value)
537 537 rec aux(value, ty : OpaType.ty) =
538 538 match ty with
539   - | {TyName_ident = "list";
540   - TyName_args =
541   - [{TyName_ident = "xhtml"; TyName_args = (_ : list(OpaType.ty)) }]} ->
542   - Xml.create_fragment(Magic.id(value))
543 539 | {TyName_ident = "xml"; ...} | {TyName_ident = "xhtml"; ...} ->
544 540 Magic.id(value)
545 541 | {TyName_ident = "text"; ...} ->
@@ -547,13 +543,20 @@ XmlConvert = {{
547 543 | {TyConst = {TyInt}} -> XmlConvert.of_int(Magic.id(value))
548 544 | {TyConst = {TyFloat}} -> XmlConvert.of_float(Magic.id(value))
549 545 | {TyConst = {TyString}} -> XmlConvert.of_string(Magic.id(value))
  546 + | {TyName_ident = "list";
  547 + TyName_args =
  548 + [{TyName_ident = "xhtml"; TyName_args = (_ : list(OpaType.ty)) }]} ->
  549 + Xml.create_fragment(Magic.id(value))
550 550 | {TyName_args = args; TyName_ident = ident} ->
551 551 OpaValue.todo_magic_container(
552 552 %%BslValue.MagicContainer.xmlizer_get%%,
553 553 ident, args, (ty -> aux(_, ty)),
554 554 aux(_, OpaType.type_of_name(ident, args)),
555 555 value, [])
556   - | _ -> {text = "Can't make an xml with " ^ OpaType.to_pretty(original_ty)}
  556 + | ty ->
  557 + if OpaTypeUnification.is_unifiable(ty, @typeval(list(xhtml))) then
  558 + Xml.create_fragment(Magic.id(value))
  559 + else {text = "Can't make an xml with {ty}"}
557 560 aux(value, original_ty)
558 561 : xml
559 562

0 comments on commit 6869f4d

Please sign in to comment.
Something went wrong with that request. Please try again.