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