Working with hex strings

Hello,

I am currently working on HTTP/2 framing, and as part of the implementation i’d like to use test data defined at: https://github.com/http2jp/http2-frame-test-case

The payload in the test files is defined as a hex string. I was wondering if there is a library or something in the stdlib that can unhex the string like: http://hackage.haskell.org/package/hex-0.1.2/docs/Data-Hex.html

I figured i’d ask before starting to implement my own utility :slight_smile:

Best,
Anurag

Hi! Is https://github.com/mirage/ocaml-hex what you want?

2 Likes

Ah thank you! Your answer made me look at the docs again and turns out I just didn’t read it properly :expressionless:

I had missed the fact that it uses polymorphic variant to define the Hex.t type.

Initially I had assumed that there wasn’t a way to create a Hex.t from a string that was already hexadecimal.