I’m looking for an implementation of arbitrary-length, immutable bit sequences in OCaml. I don’t care much about efficiency. I would like to be able to convert from and to various built in types, e.g.

```
of_int : int -> t
to_int_exn : t -> int
...
```

Finally, I would like to be able to perform standard bitwise operations on the data structure, e.g.

```
set_exn : t -> int -> bool -> t
or : t -> t -> t
and : t -> t -> t
xor : t -> t -> t
invert : t -> t
...
```

Obviously, I could roll my own implementation and use something like

```
type t = bool list
```

Before I reinvent the wheel though, I was wondering if there is already a library for this purpose? I was a bit shocked how little OCaml seems to offer when it comes to bit and byte level manipulation…

Thanks!