Immutable recursive binary search of a generic array I am new to F#. Is the following code, which represents about three hours of work, a canonical way to achieve binary search? If not, how can it be improved for readability and maintainability?

let binarySearch (array: 'a[]) (target: 'a) = 
    let rec search min max =
        match (min, max) with 
        | (min, max) when max &lt; min -&gt; -1 
        | _ -&gt; 
            let guess = ((min + max) / 2);
            match array.[guess] with
            | x when x = target -&gt; guess 
            | x when x &lt; target -&gt; search (guess + 1) (max) 
            | _ -&gt; search (min) (guess - 1) 
    search (0) (array.Length - 1) 


Aspects that I already like:


hiding the recursive function within the non-recursive function.
using pattern matching instead of if-else-then, based on suggestions here,
accepting generic types with `a.
I would strive for symmetry:

        match array.[guess] with
        | x when x &gt; target -&gt; search (min) (guess - 1) 
        | x when x &lt; target -&gt; search (guess + 1) (max) 
        | _ -&gt; guess