min :: Ord a => [a] -> Maybe a
min = foldl' go Nothing where
go Nothing a = Just a
go a0@(Just m) a
| a < m = Just a
| otherwise = a0
You can in OCaml
module Min (M : Comparable.S) : sig
val min : M.t list -> M.t option
end = struct
open M
let go a0 a = match a0 with
None -> Some(a)
| Some(m) -> if a < m then Some(a) else a0
let min l = List.fold_left go None l
end
Point being that these problems with generics are reasonably solved. There are perhaps other problems, of course. OCaml should at least be a suggestion that compilation speed isn't really one of them.