Are functions like List.hd throwing instead of returning options by design


I guess they do, but I thought I’d ask anyway. I mean, in Jane Street Base hd/tl return options and hd_exn/tl_exn throw. Should we expect _exn behavior to be the default behavior in Reason? And why? For perf? For boilerplate reduction? For more comfortable logging?


That was not a decision made by Reason. Those functions come from the OCaml standard library. An alternative is to use the BuckleScript standard library Belt which uses options instead of exceptions for the equivalent functions (see List.head, for example).


Hey, you’re right. I thought was using Belt. My bad.