Commits

camlspotter committed 6b908b6

(%!) (= Printf.sprintf) is added, ( ** ) is overridden and now a functional composition, Older functional compositions (^.) (&.) (@@) are removed.

  • Participants
  • Parent commits 1dba6d3

Comments (0)

Files changed (2)

     Hashtbl.replace cache v r;
     r
 
-let (&.) f g = fun x -> f (g x)
-let (^.) f g = fun x -> f (g x)
-let (@@) f g = fun x -> f (g x)
 external (&) : ('a -> 'b) -> 'a -> 'b = "%apply"
 external (&~) : (f:'a -> 'b) -> 'a -> 'b = "%apply"
 external (|!) : 'a -> ('a -> 'b) -> 'b = "%revapply"
 external (|>) : 'a -> ('a -> 'b) -> 'b =  "%revapply"
 
+let ( ** ) f g = fun x -> f (g x)
+external power : float -> float -> float = "caml_power_float" "pow" "float"
+
 external id : 'a -> 'a = "%identity"
 external (!&) : _ -> unit = "%ignore"
 
  
 (* Printf *)
 let sprintf = Printf.sprintf
+let (!%) = Printf.sprintf
 
 let with_ref r v f =
   let back_v = !r in

File lib/base.mli

 (** Basic functinons. They are accessible via [open Spotlib.Spot] *)
 
-(** {6 Misc things } *)
+(** {6 Common types } *)
 
 type ('a, 'b) result = [ `Ok of 'a | `Error of 'b ]
 (** Result/Either monad *)
 
-val sprintf : ('a, unit, string) format -> 'a
-(** [Printf.sprintf] is available without tying [Printf.] *)
+(** {6 Function compositions and other operators } *)
 
-val memoize : ('c -> 'd) -> 'c -> 'd
-(** Memozation by hash *)
-
-val time : ('a -> 'b) -> 'a -> 'b * float
-(** simple profiling *)
-
-(** {6 Printf style errors } *)
-
-val failwithf : ('a, unit, string, 'b) format4 -> 'a
-val invalid_argf : ('a, unit, string, 'b) format4 -> 'a
-
-(** {6 Function compositions } *)
-
-val (^.) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-val (&.) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-val (@@) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-(** funciton composition: Haskell's (.) *)
+val ( ** ) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
+(** Functional composition. Haskell's (.) 
+    Use [power] if you want to use the original [( ** )].
+*)
+external power : float -> float -> float = "caml_power_float" "pow" "float"
 
 external (&) : ('a -> 'b) -> 'a -> 'b = "%apply"
 external (&~) : (f:'a -> 'b) -> 'a -> 'b = "%apply"
 (** Haskell's ($) *)
 
+external (|>) : 'a -> ('a -> 'b) -> 'b =  "%revapply"
 external (|!) : 'a -> ('a -> 'b) -> 'b = "%revapply"
-external (|>) : 'a -> ('a -> 'b) -> 'b =  "%revapply"
-(** F#'s (|>) *)
+(** F#'s (|>). (|!) is Jane Street style. *)
 
 external id : 'a -> 'a = "%identity"
 external (!&) : _ -> unit = "%ignore"
 
+
+(** {6 Printf style errors } *)
+
+val failwithf    : ('a, unit, string, 'b) format4 -> 'a
+val invalid_argf : ('a, unit, string, 'b) format4 -> 'a
+
 (** {6 Exception handling } *)
 
 exception Finally of exn * exn
 
 val protect    : f:('a -> 'b) -> 'a -> finally: ('a -> unit) -> 'b
-val catch      : f:('a -> 'b) -> 'a -> ('b, exn) result
+val catch      : f:('a -> 'b) -> 'a -> [> ('b, exn) result ]
 val try_ignore : f:('a -> unit) -> 'a -> unit
 
 val try_bool   : f:('a -> 'b) -> 'a -> bool
     raises an exceptoin.
 *)
 
+(** {6 Misc things } *)
+
+val sprintf : ('a, unit, string) format -> 'a
+(** [Printf.sprintf] is available without tying [Printf.] *)
+
+val (!%)    : ('a, unit, string) format -> 'a
+(** [Printf.sprintf], prefix style. Bought from ITPL. *)
+
+val memoize : ('c -> 'd) -> 'c -> 'd
+(** Memozation by hash *)
+
+val time : ('a -> 'b) -> 'a -> 'b * float
+(** simple profiling *)
+