From 9f27ab1d7bb687a8acc036e749895e84c38c4c2c Mon Sep 17 00:00:00 2001 From: Drup Date: Mon, 11 Apr 2016 17:41:22 +0200 Subject: [PATCH] Make Svg wrapped function API similar to Html. --- lib/svg_f.ml | 11 ++++++----- lib/svg_f.mli | 8 ++++---- lib/svg_sigs.mli | 42 +++++++++++++++++++++--------------------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lib/svg_f.ml b/lib/svg_f.ml index cb4d76bbc..2dc2e4b7a 100644 --- a/lib/svg_f.ml +++ b/lib/svg_f.ml @@ -106,8 +106,7 @@ let string_of_paint = function module Make_with_wrapped_functions (Xml : Xml_sigs.T) - (C : Svg_sigs.Wrapped_functions - with type ('a, 'b) ft = ('a, 'b) Xml.W.ft) = + (C : Svg_sigs.Wrapped_functions with module Xml = Xml) = struct @@ -915,9 +914,11 @@ struct end -module Wrapped_functions = struct +module Wrapped_functions + (Xml : Xml_sigs.T with type ('a,'b) W.ft = 'a -> 'b) = +struct - type (-'a, 'b) ft = 'a -> 'b + module Xml = Xml let string_of_alignment_baseline = function | `Auto -> "auto" @@ -1120,4 +1121,4 @@ end module Make (Xml : Xml_sigs.T with type ('a, 'b) W.ft = ('a -> 'b)) = - Make_with_wrapped_functions(Xml)(Wrapped_functions) + Make_with_wrapped_functions(Xml)(Wrapped_functions(Xml)) diff --git a/lib/svg_f.mli b/lib/svg_f.mli index 902dd73eb..0003d1348 100644 --- a/lib/svg_f.mli +++ b/lib/svg_f.mli @@ -92,14 +92,14 @@ module Make(Xml : Xml_sigs.T with type ('a, 'b) W.ft = ('a -> 'b)) and type +'a attrib = Xml.attrib (** The standard set of wrapped functions, when [W.ft] is the regular function. *) -module Wrapped_functions : - Svg_sigs.Wrapped_functions with type (-'a, 'b) ft = 'a -> 'b +module Wrapped_functions + (Xml: Xml_sigs.T with type ('a, 'b) W.ft = 'a -> 'b) + : Svg_sigs.Wrapped_functions with module Xml = Xml (** Similar to {!Make} but with a custom set of wrapped functions. *) module Make_with_wrapped_functions (Xml : Xml_sigs.T) - (C : Svg_sigs.Wrapped_functions - with type (-'a, 'b) ft = ('a, 'b) Xml.W.ft) + (C : Svg_sigs.Wrapped_functions with module Xml = Xml) : Svg_sigs.Make(Xml).T with type +'a elt = Xml.elt and type +'a attrib = Xml.attrib diff --git a/lib/svg_sigs.mli b/lib/svg_sigs.mli index b7f395bb9..0b29022d9 100644 --- a/lib/svg_sigs.mli +++ b/lib/svg_sigs.mli @@ -968,49 +968,49 @@ end (** Wrapped functions, to be used with {!Svg_f.Make_with_wrapped_functions}. *) module type Wrapped_functions = sig - type (-'a, 'b) ft + module Xml : Xml_sigs.T val string_of_alignment_baseline : - ([< Svg_types.alignment_baseline], string) ft + ([< Svg_types.alignment_baseline], string) Xml.W.ft - val string_of_bool : (bool, string) ft + val string_of_bool : (bool, string) Xml.W.ft - val string_of_big_variant : ([< Svg_types.big_variant], string) ft + val string_of_big_variant : ([< Svg_types.big_variant], string) Xml.W.ft - val string_of_coords : (Svg_types.coords, string) ft + val string_of_coords : (Svg_types.coords, string) Xml.W.ft val string_of_dominant_baseline : - ([< Svg_types.dominant_baseline], string) ft + ([< Svg_types.dominant_baseline], string) Xml.W.ft - val string_of_fourfloats : (float * float * float * float, string) ft + val string_of_fourfloats : (float * float * float * float, string) Xml.W.ft - val string_of_in_value : ([< Svg_types.in_value], string) ft + val string_of_in_value : ([< Svg_types.in_value], string) Xml.W.ft - val string_of_int : (int, string) ft + val string_of_int : (int, string) Xml.W.ft - val string_of_length : (Svg_types.Unit.length, string) ft + val string_of_length : (Svg_types.Unit.length, string) Xml.W.ft - val string_of_lengths : (Svg_types.lengths, string) ft + val string_of_lengths : (Svg_types.lengths, string) Xml.W.ft - val string_of_number : (float, string) ft + val string_of_number : (float, string) Xml.W.ft val string_of_number_optional_number : - (float * float option, string) ft + (float * float option, string) Xml.W.ft - val string_of_numbers : (float list, string) ft + val string_of_numbers : (float list, string) Xml.W.ft - val string_of_numbers_semicolon : (float list, string) ft + val string_of_numbers_semicolon : (float list, string) Xml.W.ft - val string_of_offset : ([< Svg_types.offset], string) ft + val string_of_offset : ([< Svg_types.offset], string) Xml.W.ft - val string_of_orient : (Svg_types.Unit.angle option, string) ft + val string_of_orient : (Svg_types.Unit.angle option, string) Xml.W.ft - val string_of_paint : ([< Svg_types.paint], string) ft + val string_of_paint : ([< Svg_types.paint], string) Xml.W.ft - val string_of_strokedasharray : (Svg_types.lengths, string) ft + val string_of_strokedasharray : (Svg_types.lengths, string) Xml.W.ft - val string_of_transform : (Svg_types.transform, string) ft + val string_of_transform : (Svg_types.transform, string) Xml.W.ft - val string_of_transforms : (Svg_types.transforms, string) ft + val string_of_transforms : (Svg_types.transforms, string) Xml.W.ft end