Bitwise operators in Reason


Hi good folks! Do you have a recommended resource for learning how to do bitwise operators on bytes in ReasonML? I was looking through docs, APIs and searches but couldn’t find any pointers.

I’m still learning the ropes on ReasonML, how everything is organized and documented and how to search for answers, so apologies in advance if I missed something obvious

I appreciate your pointers :slight_smile:


OCaml has bitwise operations in its stdlib (see

They are infix operators and their names are land, lor, lxor, lnot, lsl, lsr and asr.


Thanks @anmonteiro!

If my goal is to be able to do these operations over Reason’s type Bytes and ensure that the operations are both valid for JS/Node land and OCaml, I wouldn’t be able to use OCaml stdlib, right? If it is possible, do you have any url to a snippet in which I could learn how to do it?


I assume you wanna do one byte at a time. For that you can extract the char code at each position from your value and perform bitwise operations on it.