Advertisement
Guest User

Untitled

a guest
Jan 31st, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.59 KB | None | 0 0
  1. let foo opt x fmt =
  2.   match opt with
  3.   | None -> assert false
  4.   | Some f -> ksprintf (f x) fmt
  5.  
  6. val foo : ('a -> string -> 'b) option
  7.        -> 'a
  8.        -> ('c, unit, string, 'b) format4
  9.        -> 'c = <fun>
  10.  
  11. # foo (Some (fun x s -> s)) "foo" "%s" "blah";;
  12. - : string = "blah"
  13.  
  14. let bar opt x fmt =
  15.   match opt with
  16.   | None -> ()
  17.   | Some f -> ksprintf (f x) fmt
  18.  
  19. val bar : ('a -> string -> 'b) option
  20.        -> 'a
  21.        -> (unit, unit, string, 'b) format4
  22.        -> unit = <fun>
  23.  
  24. # bar (Some (fun x s -> s)) "bar" "%s" "blah";;
  25. Error: This function is applied to too many arguments;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement