Commits

camlspotter committed ee48d65

added (|-)

Comments (0)

Files changed (2)

 
 let with_ic ic f = 
   Exn.protect' (fun () -> f ic) ~finally:(fun () -> close_in ic)
+
+let (|-) res f = f res; res
 (** Functional composition. Haskell's (.) 
     Use [power] if you want to use the original [( ** )].
 *)
+
 val ( *< ) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-(** Same as ( ** ) *)
+(** Same as ( ** ). *)
 
 val ( *> ) : ('a -> 'b) -> ('b -> 'c) -> ('a -> 'c)
-(** Functional composition in swapped order. Haskell's (>>>) *)
+(** Functional composition in swapped order. 
+    Same as Haskell's (>>>) 
+*)
 
 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 ($) *)
+(** Haskell's ($). *)
 
 external (|>) : 'a -> ('a -> 'b) -> 'b =  "%revapply"
 external (|!) : 'a -> ('a -> 'b) -> 'b = "%revapply"
 external id : 'a -> 'a = "%identity"
 external (!&) : _ -> unit = "%ignore"
 
-
-
-
-
+val (|-) : 'a -> ('a -> 'b) -> 'a
+(** "tee". [v |-- f] is [v] but [f v] is run before [v] is returned *)
 
 (** {6 Imperative operations } *)