camlspotter avatar camlspotter committed 4b1eea9

updates!

Comments (0)

Files changed (7)

 - Tweaked String.{is_prefix, is_postfix} labels
 - Added String.{is_prefix', is_postfix', drop_postfix}
 - Added ok, ng, !!%
-* failwith and invalid_arg are overridden by failwithf and invalid_argf
 - Added (*>)
 
 2.1.2
  
 (* Printf *)
 let sprintf = Printf.sprintf
+let ksprintf = Printf.ksprintf
 let (!%) = Printf.sprintf
 let (!!%) = Format.eprintf
 
 val sprintf : ('a, unit, string) format -> 'a
 (** [Printf.sprintf] is available without tying [Printf.] *)
 
+val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b
+(** [Printf.ksprintf] is available without tying [Printf.] *)
+
 val (!%)    : ('a, unit, string) format -> 'a
 (** [Printf.sprintf], prefix style. Bought from ITPL. *)
 
 let failwithf fmt = Printf.kprintf failwith fmt
-let failwith = failwithf
 let invalid_argf fmt = Printf.kprintf invalid_arg fmt
-let invalid_arg = invalid_argf
 
 exception Finally of exn * exn
 ;;
 (** {6 Printf style errors } *)
 
 val failwithf    : ('a, unit, string, 'b) format4 -> 'a
-val failwith     : ('a, unit, string, 'b) format4 -> 'a
-(** [failwith] is overridden by [failwithf], since
-
-    Mistyping [failwith "hello %s" "world"] instead of [failwithf "hello %s" "world"]
-    ignores the second argument.
-
-    Use [Pervasives.failwith] if you need one with type : string -> 'a
- *) 
 
 val invalid_argf : ('a, unit, string, 'b) format4 -> 'a
-val invalid_arg  : ('a, unit, string, 'b) format4 -> 'a
 
 (** {6 Exception handling } *)
 
   let buf = Buffer.create 100 in
   let ppf = formatter_of_buffer buf in
   kfprintf (fun ppf -> flush ppf; Buffer.contents buf) ppf fmt
+
+let ksprintf f fmt =
+  let buf = Buffer.create 100 in
+  let ppf = formatter_of_buffer buf in
+  kfprintf (fun ppf -> flush ppf; f (Buffer.contents buf)) ppf fmt
 val sprintf : ('a, t, unit, string) format4 -> 'a
   (** [sprintf] with a better type than the orignal *)
 
+val ksprintf : (string -> 'a) -> ('b, t, unit, 'a) format4 -> 'b
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.