List.iteri doesn't have the 'right' signature

Issue #2 resolved
leonidr created an issue

I don't know if you care about this but:

a list -> f:(int -> 'a -> 'b) -> unit

Comments (3)

  1. Sebastien Mondet repo owner

    That's interesting; I never noticed because I always build with -strict-sequence.

    $ ocaml
    ...
    #   let iteri l ~f =
          ignore (fold l ~init:0 ~f:(fun i x -> f i x; i + 1))
     ;;
      val iteri : 'a list -> f:(int -> 'a -> 'b) -> unit = <fun>
    

    Vs

    $ ocaml -strict-sequence
    ...
    #   let iteri l ~f =
          ignore (fold l ~init:0 ~f:(fun i x -> f i x; i + 1))
     ;;
      val iteri : 'a list -> f:(int -> 'a -> unit) -> unit = <fun>
    

    Hence, is this a bug or a feature (i.e. we obey the user preference of not using the -strict-sequence)?

  2. leonidr reporter

    I do think of it as a bug as I wouldn't want the code to compile unless f does has a unit return type, which I experienced yesterday. But, this is trivial, I threw up a PR since I raised this issue.

  3. Log in to comment