2

I don't understand that the function (my_path_mapper) doesn't subject to the value restriction.

# let rec my_map ~f l =
  match l with
    [] -> []
  | h::t -> f h::my_map f t;;
      val my_map : f:('a -> 'b) -> 'a list -> 'b list = <fun>
# let my_path_mapper =
  my_map ["/usr/sbin"; "/usr/bin"; "/sbin"; "/bin"; "/usr/games"; "/usr/local/games"];;
  val my_path_mapper : f:(string -> 'a) -> 'a list = <fun>

Please teach me Why ?

1 Answers1

1

OCaml has a "relaxed value restriction." You can read about it here:

Jacques Garrigue, Relaxing the Value Restriction

Here is a previous discussion on StackOverflow:

When does the relaxed value restriction kick in in OCaml?

Community
  • 1
  • 1
Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108