Commits

Paweł Wieczorek committed 7216d3b

minor

  • Participants
  • Parent commits 8bfb48c

Comments (0)

Files changed (2)

File src/Prioritized.ml

 
 let psp_group = psp_group_with_priority psp_min_priority
 
+let psp_group_map_with_priority prio f xs = psp_group_with_priority prio (List.map f xs)
+
+let psp_group_map f xs = psp_group_map_with_priority psp_min_priority f xs
+
 let psp_indent_group_with_priority prio xs = (prio, Basic.sp_indent (List.map get_painter xs))
 
 let psp_indent_group = psp_indent_group_with_priority psp_min_priority
 
 let any_multiline   = List.exists is_multiline
 
+let psp_before a b = psp_group [a; b]
+
 (*--------------------------------------------------------------------------------------------------------------------
  * Basic combinators
  *)
     (fun prio prio_param -> prio > prio_param)
 
 (*--------------------------------------------------------------------------------------------------------------------
+ * List
+ *)
+
+let _psp_list after f_bracket sep = function
+    | [] ->
+        f_bracket (psp_group [psp_empty; after])
+
+    | y::ys ->
+        let elem x = psp_group [sep; x; after] in
+        f_bracket (psp_group [y; after; (psp_group_map elem ys)])
+
+let psp_list f_bracket sep xs = 
+    if any_multiline xs
+    then _psp_list psp_break f_bracket sep xs
+    else _psp_list psp_empty f_bracket sep xs
+
+let psp_list_with_priority priority f_bracket sep xs =
+    psp_reprioritize priority (psp_list f_bracket sep xs)
+
+let psp_list_map f_bracket sep f xs = 
+    psp_list f_bracket sep (List.map f xs)
+
+let psp_list_map_with_priority priority f_bracket sep f xs =
+    psp_list_with_priority priority f_bracket sep (List.map f xs)
+
+(*--------------------------------------------------------------------------------------------------------------------
  * Output
  *)
 

File src/Prioritized.mli

  *)
 
 
+(********************************************************************************************************************)
 (** {2 Painter representation} *)
 
 (** painter type *)
 val psp_reprioritize : priority -> painter -> painter
 
 
+(********************************************************************************************************************)
 (** {2 Fundamental painters} *)
 
 (** Paints a word. *)
 val psp_value_bool : bool -> painter
 
 
+(********************************************************************************************************************)
 (** {2 Line breaking} *)
 
 
 val psp_newline : painter
 
 
+(********************************************************************************************************************)
 (** {2 Basic operands and painters} *)
 
 
 val psp_indent : painter -> painter
 
 
+(********************************************************************************************************************)
 (** {2 Grouping} *)
 
 
 
 val psp_indent_group_with_priority_when_multiline : priority -> painter list -> painter
 
+(********************************************************************************************************************)
 (** {2 Brackets} *)
 
 
 
 val psp_decide_std_bracket : bool -> painter -> painter
 
+(********************************************************************************************************************)
 (** {2 Associative operators} *)
 
 (** associtivity *)
                  -> 'a -> painter -> painter -> painter
 
 
+(********************************************************************************************************************)
+(** {2 Lists} *)
+
+val psp_list_with_priority : priority -> (painter -> painter) -> painter -> painter list -> painter
+
+val psp_list : (painter -> painter) -> painter -> painter list -> painter
+
+val psp_list_map_with_priority : priority -> (painter -> painter) -> painter -> 
+    ('a -> painter) -> 'a list -> painter
+
+val psp_list_map: (painter -> painter) -> painter -> 
+    ('a -> painter) -> 'a list -> painter
+
+(********************************************************************************************************************)
 (** {2 Various helpers} *)
 
 (**
 val psp_with_own_priority : ('a -> priority) -> (priority -> 'a -> painter) -> 'a -> painter
 
 
+(********************************************************************************************************************)
 (** {2 Output} *)
 
 (**