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


#1

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?


#2

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).


#3

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