fork download
  1. (* comments after each toplevel definition == what REPL outputs *)
  2.  
  3. class ['a] adder next (init : 'a) = object
  4. val mutable sn = init
  5. method get_next =
  6. sn <- next sn;
  7. sn
  8. end
  9. (*
  10. class ['a] adder :
  11.   ('a -> 'a) -> 'a -> object val mutable sn : 'a method get_next : 'a end
  12. *)
  13.  
  14. let govno_lambda = fun x -> x + 1
  15. (*
  16. val govno_lambda : int -> int = <fun>
  17. *)
  18.  
  19. class govno_adder = [int] adder govno_lambda
  20. (*
  21. class govno_adder : int -> [int] adder
  22. *)
  23.  
  24. let ad = new govno_adder 10
  25. (*
  26. val ad : govno_adder = <obj>
  27. *)
  28.  
  29. let () = print_int ad#get_next
  30. (*
  31. 11- : unit = ()
  32. *)
  33.  
Success #stdin #stdout 0.02s 2736KB
stdin
Standard input is empty
stdout
11