Detect single-character xor (OCaml)
Congrats on tackling cryptopals! These are great exercises and very interesting to learn new languages and techniques.

Syntax

Remove the type annotations

In most cases in OCaml, you don't need any type annotations. So instead of:

let make_result (input : xor_input) c : result =


It's more usual to write:

let make_result input c =


The reason is that for exposed functions, the type will be in the .mli file, and for local functions, it's only one key binding away in your editor thanks to merlin.

Pipelines

The pipe operator is powerful and works well in some cases like your main function, but combined with partial application and infix operators, it can become hard to read.

I'd rewrite:

fun l -&gt; int_of_char l |&gt; (lxor) c |&gt; char_of_int


As:

fun l -&gt; char_of_int (c lxor (int_of_char l))


Pattern tricks

In places like this:

let (Xor_input input) =


You can omit the parens and just write:

let Xor_input input =


You can also perform several layers of pattern matching in one step. So rather than writing

let sort_results { score = first; _ } { score = second; _ } =
  let (Score first_val) = first in
  let (Score second_val) = second in


You can write:

let sort_results { score = Score first_val; _ } { score = Score second_val; _ } =


Record shorthand syntax

When building a record, parts that look like label = label can be written just label. So you can rename variables and change:

let make_result input c =
  let output = xor c input in
  { test_char = char_of_int c; score = make_ranking output; xor_input = input; xor_output = output }


To:

let make_result xor_input c =
  let xor_output = xor c xor_input in
  { test_char = char_of_int c; score = make_ranking output; xor_input; xor_output }


Type design

I don't think that the xor_input and xor_output bring a lot here. You're probably be as OK with plain strings.

Other remarks

You are sorting a whole list just to get the minimal element. There is probably a function to do that in core (and it will be linear).

Instead of fprintf stdout, you can just use printf.

That's it! Have a nice journey learning OCaml and please post other examples on this site :)