Option infix operator. Identity function causes an error

Hey, a small change which looks to be doing nothing actually causes a compile error. Why would that happen?

This runs just fine:

open Core
open Base.Option.Monad_infix

let f () = 
  [1;2;3]
  |>
  Option.return
  >>|
  List.map ~f:string_of_int
  >>|
  String.concat ~sep:","
  >>|
  print_endline


However, if I insert an identity function fun s -> s there, it produces an error:

open Core
open Base.Option.Monad_infix

let f () = 
  [1;2;3]
  |>
  Option.return
  >>|
  List.map ~f:string_of_int
  >>|
  String.concat ~sep:","
  >>|
  fun s -> 
    s
  >>| 
  print_endline
Error: This expression has type string but an expression was expected of type
         'a option

I found a workaround, I wonder why this works:

let f () = 
  [1;2;3]
  |>
  Option.return
  >>|
  List.map ~f:string_of_int
  >>|
  String.concat ~sep:","
  >>|
  (
  fun s -> 
    s
  )
  >>| 
  print_endline

Your first example is parsed as (removing the whitespace)

>>|
  (fun s -> s >>| print_endline)

The extent of fun is loosely speaking as big as possible.

Thank you, this makes sense.