let compare_substring_strict (a, idxa, lena) (b, idxb, lenb) =
let check_a = lazy (idxa >= 0 && lena >= 0 && idxa + lena <= (length a)) in
let check_b = lazy (idxb >= 0 && lenb >= 0 && idxb + lenb <= (length b)) in
if lena = 0 && lenb = 0 then Some 0
else
(if lena = 0 then (if Lazy.force check_b then Some (-1) else None)
else
(if lenb = 0 then (if Lazy.force check_a then Some (1) else None)
else
(if not (Lazy.force check_a) || not (Lazy.force check_b) then None
else
Some (compare_substring (a, idxa, lena) (b, idxb, lenb)))))